跳到主要内容
CNode

为什么我delete总是Cannot GET /呢?

问答
Dduolew发布于 11 年前最后回复 11 年前
450720

我用的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,却不能得到删除页面,求大侠,这是为什么呢??

查看回复

回复 (4)

D
duolew#411 年前

谢谢各位大神,我明白啦~~

A
ayiis#311 年前
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("DELETE","/del_user",true);
xmlhttp.send();

楼上说得很清楚了,我补一下代码

M
MiguelValentine#211 年前

app.delete method:delete

I
i5ting#111 年前

delete是http verb,你要在ajax或者curl或postman里才能用

浏览器直接打开是get

自己补https://github.com/i5ting/node-http

参与回复

登录后即可参与回复。登录