Abdennour TOUMI Abdennour TOUMI - 1 month ago 12
Node.js Question

PUT with 'superagent' module

Reading

documentation, There is no distinguish between POST & PUT request :

request.post('/user')
.set('Content-Type', 'application/json')
.send('{"name":"tj","pet":"tobi"}')
.end(callback)


How to do PUT request using this package ?

Answer

DELETE, HEAD, POST, PUT and other HTTP verbs may also be used, simply change the method name.

So,

request.put('/user')
    .set('Content-Type', 'application/json')
    .send('{"name":"tj","pet":"tobi"}')
    .end(callback)
Comments