如何向HTML页面呈现“JSON get”请求? [关闭]

问题描述 投票:-1回答:1

如何向HTML页面呈现“JSON get”请求?

我的代码:

var mId = 'MZWZMVZWJWY24';

var request = require("request");

var options = { method: 'GET',
    url: 'https://api.clover.com:443/v3/merchants/'+ mId +'/address',
    headers: {
        'Cache-Control': 'no-cache',
        Authorization: 'Bearer efcbbf20-e31f-11db-892c-eddc691f7a33'
    }
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});

我想将结果发送到page.html

javascript html node.js
1个回答
3
投票

由于您使用的是Node.JS,因此您还必须创建Web服务器才能呈现您收到的JSON数据。你可以使用快递和把手来做到这一点。

您将使用服务器呈现HTML页面,而把手用于在页面上显示数据。

如果您有兴趣,互联网上有很多关于把手和Node.JS的教程

© www.soinside.com 2019 - 2024. All rights reserved.