Search code examples
node.jsputsuperagent

PUT with 'superagent' module


Reading Superagent 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 ?


Solution

  • 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)