[英]External request in Runkit endpoint
Runkit ( https://runkit.com ), has a service where you can publish endpoints. Runkit( https://runkit.com )提供一项服务,您可以在其中发布端点。
I am looking to publish an enpoint that calls an external server for data, and returns that data. 我希望发布一个可以调用外部服务器获取数据并返回该数据的方法。 It seems as though I am unable to accomplish this.
看来我无法完成这项工作。 Here's what I've tried:
这是我尝试过的:
var got = require("got");
var githubStatusJson = (await got("https://status.github.com/api/status.json", { json : true })).body;
exports.endpoint = function(request, response) {
response.end("Hello world!");
}
The error message I am getting is : 我收到的错误消息是:
{
error: "invalid_server",
message: "The requested document does not export an 'endpoint' function. Read more about endpoint: https://runkit.com/docs/endpoint"
}
Got a response from the runkit team that works! 得到了运行工具团队的回应!
const getJSON = require("async-get-json");
const getGitHubAPIStatus = getJSON("https://status.github.com/api/status.json");
module.exports.endpoint = async function (request, response)
{
response.end(JSON.stringify(await getGitHubAPIStatus));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.