Ich baue eine (RESTful) Node.js API, mit this tutorial.REST api/postman - Kann die Route nicht bekommen Fehler
Ich habe nade ein server.js
const express = require('express');
const MongoClient = require('mongodb').MongoClient;
const bodyParser = require('body-parser');
const app = express();
const port = 8080;
app.listen(port,() => {
console.log('We are live on ' + port);
});
ich meine Server ausgeführt werden können und die Meldung:
Wir leben sind auf 8080
mein index.js
const noteRoutes = require('./note_routes');
module.exports = function(app, db) {
noteRoutes(app, db);
// Other route groups could go here, in the future
};
und meine node_routes.js
//create a node
module.exports = function(app, db) {
app.post('/notes', (req, res) => {
// You'll create your note here.
res.send('Hello')
});
};
index.js
und node_routes.js
sind sowohl innerhalb als app\routes\
Ich habe auch den Post Mann App heruntergeladen hat, auf einfache Anfragen
zu machen, und ich erhalte die Fehler
Can not POST/Notizen
, was mache ich falsch ?? Ich kann es nicht herausfinden!
try index.js in server.js importieren – zabusa
diese ein Add in server.js . require ('./ app/routes') (app, {}); –