240
世界上有10种人,一种懂二进制,另一种不懂二进制。

nodejs后台向后台get请求

1 前言

有时在nodejs写的服务端某方法需要向服务端另一个接口发送get请求,可以使用第三方库,然后直接使用即可,此文章只是用来记录使用

2 方法

2.1 get 请求

//1. Install
npm install --save request
//2. back-end
var request = require('request');
request('http://www.example.com/create?account=user&sign', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) 
  }
})  

2.2 post请求

略,见参考链接

3 参考

链接:http://blog.csdn.net/dreamer2020/article/details/52074516

posted @ 2018-03-14 20:35  unionline  阅读(577)  评论(0)    收藏  举报