簡體   English   中英

Runkit端點中的外部請求

[英]External request in Runkit endpoint

Runkit( https://runkit.com )提供一項服務,您可以在其中發布端點。

我希望發布一個可以調用外部服務器獲取數據並返回該數據的方法。 看來我無法完成這項工作。 這是我嘗試過的:

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!");
}

我收到的錯誤消息是:

{
error: "invalid_server",
message: "The requested document does not export an 'endpoint' function. Read more about endpoint: https://runkit.com/docs/endpoint"
}

得到了運行工具團隊的回應!

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM