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. [Leetcode] Repeated DNA Sequences

    All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACG ...

  2. PHP 小数点保留两位【转】

    最近在做统计这一块内容,接触关于数字的数据比较多, 用到了三个函数来是 数字保留小数后 N 位: 接下来简单的介绍一下三个函数: 1.number_format echo number_format( ...

  3. 纯CCS绘制三角形箭头图案

    用CSS绘制三角形箭头.使用纯CSS,你只需要很少的代码就可以创作出各种浏览器都兼容的三角形箭头! CSS代码: /* create an arrow that points up */ div.ar ...

  4. dede 调用原图的路径

    步骤:1修改include/extend.func.php 添加如下代码: //取原图地址function bigimg($str_pic){$str_houzhi=substr($str_pic,- ...

  5. Web前端面试之HTML

    1. 对WEB标准以及W3C的理解与认识 web标准规范要求,书写标签闭合.小写.不乱嵌套,可提高搜索机器人对网页内容的搜索几率.--- SEO 使用外链css和js脚本,结构与行为.结构与表现分离, ...

  6. jasmine入门

    本文来自http://blog.fens.me/nodejs-jasmine-bdd 粉丝日志 张丹   前言TDD(Test Driven Development)测试驱动开发,是敏捷开发中提出的最 ...

  7. python 函数之day3

    一 函数的语法及特性 什么是函数? 定义:函数是一个功能通过一组语句的集合,由名字(函数名)将其封装起来的代码块,要想执行这个函数,只要调用其函数名即可. 特性: 减少重复代码 使程序变的可扩展 使程 ...

  8. Python之路Day17-jQuery

    本节内容: jQuery 参考:http://jquery.cuishifeng.cn/ 模块  <==>类库 Dom/Bom/JavaScript的类库 版本:1.x   1.12 2. ...

  9. JeeSite学习笔记~代码生成原理

    1.建立数据模型[单表,一对多表,树状结构表] 用ERMaster建立数据模型,并设定对应表,建立关联关系 2.系统获取对应表原理 1.怎样获取数据库的表 genTableForm.jsp: < ...

  10. angular学习之路(一)

    angular是什么? angular是一个用于设计动态web应用的结构框架! 它不仅仅是一个JavaScript框架,他的核心其实是对HTML标签的增强. 何为HTML标签的增强?其实就是使用标签完 ...