Reputation: 3014
Runkit (https://runkit.com), has a service where you can publish endpoints.
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"
}
Upvotes: 2
Views: 750
Reputation: 3014
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));
}
Upvotes: 2