1.npm install art-template
2.npm  install request
3.在app.js中加入以下代码转html:

var template = require('art-template');
template.config('base', '');
template.config('extname', '.html');
app.engine('.html', template.__express);
app.set('view engine', 'html');

4.在routes/index.js中

var express = require('express');
var router = express.Router();
//var request=require('request');
var request = require("request");
/* GET home page. */
router.get('/', function(req, res, next) {
var headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json-rpc',
'keyname':'XXX'
};
var options = {
url: "XXX",
method: 'POST',
headers: headers,
form: {jsonrpc:'{"method": "XXX", "params": ["XXXXX"], "id": X}'}
};
request(options, function (error, response, body) {
res.render("index", {title:res.statusCode.toString() + " " + body});
});
}); module.exports = router; 将对应的keyname、url、method、params、id改为自己的值
运行结果: 200 {"jsonrpc":"2.0","result":"XXXXX测试数据","id":X}

NodeJS POST Request Over JSON-RPC的更多相关文章

  1. [转]nodejs使用request发送http请求

    本文转自:https://blog.csdn.net/dreamer2020/article/details/52074516/ 在nodejs的开发中,有时需要后台去调用其他服务器的接口,这个时候, ...

  2. 測试JSON RPC远程调用(JSONclient)

    #include <string> #include <iostream> #include <curl/curl.h> /* 标题:JSonclient Auth ...

  3. 客户端通过Feign发起请求 服务端通过request取 json对象

    @RestController @RequestMapping(value = "test") public class TestServer { @RequestMapping( ...

  4. 获取 request 中 json 数据

    import java.io.IOException; import javax.servlet.http.HttpServletRequest; /** * request 对象的相关操作 * @a ...

  5. flask request 获取json内容2种方式

    # -*- coding: utf-8 -*-from flask import request, jsonify, json, Moduleimport loggingfrom web.utils. ...

  6. 如何使用python内置的request发送JSON格式的数据

    使用步骤如下: 一.如果想发送json格式的数据,需要使用request模块中的Request类来创建对象,作为urlopen函数的参数 二.header中添加content-type为applica ...

  7. Nodejs中request出现ESOCKETTIMEDOUT解决方案

    做需求的时候,使用Nodejs的request批量请求某一个接口,由于接口超时,出现 ESOCKETTIMEDOUT,程序中断 为了让程序遇到 ESOCKETTIMEDOUT 之后能够继续执行下去,需 ...

  8. nodejs get/request

    灌水评论示例: var http = require('http'); var querystring = require('querystring'); var postData = queryst ...

  9. request获取json

    $.ajax({ type:'post', url:'${ctx}/recordServiceController/queryDetail.do', //contentType:'applicatio ...

  10. Google Volley: How to send a POST request with Json data?

    sonObjectRequest actuallyaccepts JSONObject as body. From http://arnab.ch/blog/2013/08/asynchronous- ...

随机推荐

  1. [BZOJ1562][ZJOI2007] 最大半连通子图

    Description Input 第一行包含两个整数N,M,X.N,M分别表示图G的点数与边数,X的意义如上文所述.接下来M行,每行两个正整数a, b,表示一条有向边(a, b).图中的每个点将编号 ...

  2. 2016windows(10) wamp 最简单30分钟thrift入门使用讲解,实现php作为服务器和客户端的hello world

    2016最简单windows(10) wamp 30分钟thrift入门使用讲解,实现php作为服务器和客户端的hello world thrift是什么 最简单解释 thrift是用来帮助各个编程语 ...

  3. Flask_more1

    #DB ``` import os basedir = os.path.abspath(os.path.dirname(__file__))   SQLALCHEMY_DATABASE_URI = ' ...

  4. 利用浏览器LocalStorage缓存图片,视频文件

    文章路径:https://hacks.mozilla.org/2012/02/saving-images-and-files-in-localstorage/

  5. asp.net mvc引用控制台应用程序exe

    起因:有一个控制台应用程序和一个web程序,web程序想使用exe程序的方法,这个时候就需要引用exe程序. 报错:使用web程序,引用exe程序 ,vs调试没有问题,但是部署到iis就报错,如下: ...

  6. css技巧

    1.实现position为fixed与absolute值时居中定位: 给需要定位的元素块外加一层div盒子,外层div盒子存在于文档流中,让外层div盒子居中定位并设置position属性为relat ...

  7. HDU2818 并查集

    Building Block Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  8. redis主从复制配置

    master配置 主要是下面配置 # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the # intern ...

  9. mysql远程连接命令

    mysql远程连接命令   一.MySQL 连接本地数据库,用户名为“root”,密码“123”(注意:“-p”和“123” 之间不能有空格) C:\>mysql -h localhost -u ...

  10. The Solution of UESTC 2016 Summer Training #1 Div.2 Problem C

    Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/C Description standard input/output After ...