Home > Web Front-end > JS Tutorial > body text

node.js [superAgent] request usage example_node.js

WBOY
Release: 2016-05-16 16:09:29
Original
1303 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!