javascript - I use routes in my Node.JS app and when I try to open one of the routes from the browser I get an error -


that's app. when try open ip/delete error

cannot /delete

i'm following tutorial, https://www.tutorialspoint.com/nodejs/nodejs_express_framework.htm

var express = require('express'); var app = express();  app.use(express.static('public'));  app.get('/', function(req, res) {         console.log("got request");         res.send('gbarena labs'); })  app.post('/', function(req, res) {         console.log("got post request"); })  app.delete('/delete', function(req, res) {         res.send('delete');         console.log("got delte request"); })  app.listen(8081); 

you can't navigate delete. have send delete request. in example :

<a href="/delete">my delete link<a/> sent request , not delete.

in order hit delete endpoint, have use ajax library jquery $.ajax , using

$.ajax({     url: '/delete',     type: 'delete',     success: function(result) {         // result     } }); 

from client side.

there many ways, suggest looking : http verbs


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -