Home >Web Front-end >JS Tutorial >node.js [superAgent] request usage example_node.js

node.js [superAgent] request usage example_node.js

WBOY
WBOYOriginal
2016-05-16 16:09:291351browse

post request:

Copy code The code is as follows:

request.post('/api/pet')
.end(function(resp,err){
If (resp.body.status===200) {
alert('yay got ' JSON.stringify(res.body));
} else {
         return next(resp.body);
}
});

get request:

Copy code The code is as follows:

request.get('/api/pet')
...
});

delete request:

Copy code The code is as follows:

request.del('/api/pet')
...
});

put request:

Copy code The code is as follows:

request.put('/api/pet')
...
});

The above is the entire content of this article. I hope it will be helpful to everyone learning node.js.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn