Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
JSON Endpoint Demo1
node v4.9.1
version:
2.0.0
endpoint
share
tweet
// https://runkit.com/runkit/json-endpoint-example-1 // Test with https://runkit.io/suntong/json-endpoint-demo1/branches/master?url=http://google.com, // https://runkit.io/runkit/json-endpoint-example-1/branches/master?url=http://google.com var endpoint = require("@runkit/runkit/json-endpoint/1.0.0") var request = require("request") // peer dependency var requestPromise = require("request-promise") var cheerio = require("cheerio") endpoint(module.exports, async function(request) { try { var html = await requestPromise(request.query.url) var page = cheerio.load(html) } catch(e) { return {error: "could not retrieve page"} } return { title: page("title").text() || "no title", ok: true } })
https://runkit.io/suntong/json-endpoint-demo1/branches/master?url=http://google.com
Loading…
no comments
sign in
to comment