node.js [superAgent] 请求使用示例

  作者:bea

post请求: 代码如下: 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.get('/api/pet')
post请求:


代码如下:


 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.get('/api/pet')
     ...
   });



delete请求:


代码如下:


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



put请求:


代码如下:


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



以上就是本文的全部内容了,希望能对大家学习node.js有所帮助。


有用  |  无用

猜你喜欢