axios显示数据库数据

db.js

const mongoose = require(‘mongoose‘);
mongoose.connect(‘mongodb://用户xxxx:密码xxxxx@连接xxxxxx:端口xxxxx/数据库名xxxxx‘, {useNewUrlParser:true});
mongoose.set(‘useNewUrlParser‘, true);
mongoose.set(‘useFindAndModify‘, false);
mongoose.set(‘useCreateIndex‘, true);

const db = mongoose.connection;
db.once(‘error‘, () => console.log(‘Mongo connection error‘));
db.once(‘open‘, () => console.log(‘Mongo connection successed‘));

const model = mongoose.Schema({
_id: String,
name: String,
desc: String,
project_name: String,
create_date: String
});

const Models = {
bugs: mongoose.model(‘bugs‘, model),
ideas: mongoose.model(‘ideas‘, model),
};

module.exports = Models;

index.js

const express = require(‘express‘);
const app = express();
const api = require(‘./api/api‘);
const fs = require(‘fs‘);
const path = require(‘path‘);
const bodyParser = require(‘body-parser‘);
const cors = require(‘cors‘);
app.use(cors({ origin: ‘*‘ }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(api);
app.listen(3000);
console.log(‘success listen…………‘);
---------------------

axios显示数据库数据

上一篇:2019 全网 iOS 面试题以及答案总结!


下一篇:夺命雷公狗—玩转SEO---78---手机排名优先索引---MIP改造