node.js - nodejs为什么我delete总是Cannot GET /呢?
PHP中文网
PHP中文网 2017-04-17 13:06:45
0
3
885

我用的Express,我是下边这么写的

var express = require('express');
var app = express();

app.delete('/del_user', function (req, res) {
    console.log("/del_user 响应 DELETE 请求");
    res.send('删除页面');
})

var server = app.listen(8081, function () {
    var host = server.address().address
    var port = server.address().port
    console.log("应用实例,访问地址为 http://%s:%s", host, port)
})

我打开127.0.0.1:8081/del_user总是得到Cannot GET /del_user,却不能得到删除页面,求大侠,这是为什么呢??

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
刘奇

Enter the URL in the browser address bar, and the browser will request the server in the form of GET, but your program does not have the logic to handle GET. To send a DELETE request, you can find a RESTClient tool to test the effect.

黄舟

Write a form and change the submission type to delete

Peter_Zhu

curl -X DELETE localhost:3000/del

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template