nodejs的jsonrpc调用

贺靖
2023-12-01

记录下使用nodejs发送jsonrpc请求:

var express = require('express');
var router = express.Router();
var request = require("request");

/* GET home page. */
router.get('/', function (req, res, next) {

  var headers = {
     'User-Agent': 'Super Agent/0.0.1',
     'Content-Type': 'application/x-www-form-urlencoded',
     'Accept': 'application/json-rpc',
     'keyname':'xx'
   };

  var options = {
    url: "http://192.168.20.131:8088",
    method: 'POST',
    headers: headers,
    form: {jsonrpc:'{"method": "ses/user/stringme", "params": ["XXXXX"], "id": 4}'}
  };

    request(options, function (error, response, body) {
        res.render("index", {title:res.statusCode.toString() + " " + body});
    });
});

module.exports = router;

 

转载于:https://my.oschina.net/caiya928/blog/784036

 类似资料: