📜  获取外部 api 节点 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:12.110000             🧑  作者: Mango

代码示例1
var express = require('express');
var router = express.Router();
var request = require('request');

router.get('/', function(req, res, next) {
  request({
    uri: 'http://www.giantbomb.com/api/search',
    qs: {
      api_key: '123456',
      query: 'World of Warcraft: Legion'
    },
    function(error, response, body) {
      if (!error && response.statusCode === 200) {
        console.log(body)
      }
    }
  });
});

module.exports = router;