我正在尝试运行存储过程来将电影添加到数据库中。我有'getAllFilms'的存储过程可以正常工作但是当我运行addFilm时,它会出现一个错误:'Not Found'
在mySQL中,存储过程有效:
CREATE DEFINER=`sherattd`@`%` PROCEDURE `addFilm`(in Title varchar(45), in
Year int, in Director varchar(45), in Stars varchar(45), in Review
varchar(45))
BEGIN
insert into films (title, year, director, stars, review) values (Title,
Year, Director, Stars, Review);
END
当我在visual studio上调用它时,它会出错:
var express = require('express');
var router = express.Router();
var config = require('config');
var http = require("http");
var mysql = require('mysql');
var request
//Add Film
router.post('/api/addFilm/:title/:year/:director/:stars/:review', function (req, res) {
console.log("hello");
var Title = req.params['title'];
var Year = req.params['year'];
var Director = req.params['director'];
var Stars = req.params['stars'];
var Review = req.params['review'];
var con = mysql.createConnection({
host: config.get('EPAssignment.database.host'),
user: config.get('EPAssignment.database.user'),
password: config.get('EPAssignment.database.password'),
database: config.get('EPAssignment.database.database')
});
console.log("hello x2");
con.connect(function (err) {
if (err) throw err;
con.query("CALL addFilm('" + Title + "', '" + Year + "', '" + Director + "', '" + Stars + "', '" + Review + "');", function (err, result, fields) {
if (err) throw err;
console.log(result);
console.log("hello x3");
res.send(result[0]);
});
});
});= require('request');
当我调用它时,使用(Test,2000,Test,Test,Test)的测试值,控制台记录:
App GET [404] /api/addFilm/Test/2000/Test/Test/Test
由于