如何通过API调用返回json数组

时间:2018-09-17 05:30:45

标签: node.js api

先生,我已经构造了创建json数组集的请求。

request('https://testing.com/fund.jsp', function (error, response, body) {
...

 console.log('jsonArray : ', jsonArray);


});

如果我想通过localhost:3000 / getFund获取API并返回jsonArray作为结果,请告诉我下一步该怎么做  ?

1 个答案:

答案 0 :(得分:1)

您在使用ExpressJs吗?如果是这样,您可以使用response.json

response.json({ jsonArray : jsonArray });

有关更多信息,您可以看看here