// Express use const = Express the require ( 'Express' ) const App = Express () app.listen ( 3001, () => { the console.log ( "HTTP: // localhost: 3001" ) }) app.use ( express.json ()) app.get ( '/', (REQ, RES) => { the console.log ( "Hello Express!" ) }) // CORS app.use (the require ( 'CORS') ()) // middleware cors introduced and used to solve the problem of cross-domain // Mongoose use const = Mongoose the require ( 'Mongoose' ) mongoose.connect ( 'MongoDB: //127.0.0.1: 27017 / db_name',{ // db_name name can easily play useNewUrlParser: true }) const model = new mongoose.Schema({ title: { type: String }, body: { type: String } }) const Model = mongoose.model('Model', model)
After the node test.js