最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

REST apipostman

运维笔记admin13浏览0评论

REST api / postman

REST api / postman

我正在使用this tutorial构建一个(RESTful)Node.js API。

我做了一个qazxsw poi

server.js

我可以运行我的服务器并看到消息:

我们活在8080年

我的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); });

index.js

和我的const noteRoutes = require('./note_routes'); module.exports = function(app, db) { noteRoutes(app, db); // Other route groups could go here, in the future };

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都在node_routes.js

我还下载了post man app,以便提出简单的请求

我得到了错误

不能POST /备注

app\routes\

我究竟做错了什么??我想不明白!

回答如下:

你的有一个错误

你缺少server.js

应该:

require('./app/routes')(app, {});

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论