我是Node.js的新手,我正在使用下面的教程。
http://www.9lessons.info/2017/02/create-restful-api-nodejs-mysql.html
现在我遇到的问题是使用post方法。当我调用任何其他方法时,Get方法会出现此错误:
https://github.com/srinivastamada/NodeRestful/blob/master/server.js
server.route({
method: 'POST',
path: '/messages',
handler: function (request, reply) {
const uid = request.payload.uid;
console.log(uid);
connection.query('SELECT * FROM messages WHERE uid_fk = "' + uid + '"', function (error, results, fields) {
if (error) throw error;
console.log(results);
reply(results);
});
},
config: {
validate: {
payload: {
uid: Joi.number().integer()
}
}
}
});