jasonette-1

node v6.17.1
version: 15.0.0
endpointsharetweet
const giphy = require( 'giphy-api' )() const c = console // api const getCats = giphy.search("cats") // lib let cats = await getCats cats = cats.data // test code // c.log(cats) // full response let cat_gifs = [] cats.forEach((cat) => { cat_gifs.push(cat.images.downsized_large.url) }) // c.log(cat_gifs) // only large gifs // cat_gifs.forEach((gif) => { // c.log(gif) // })
^ | | getCats | Endpoint | | | v
// it works, we have cat_gifs from last snippet (note the line numbers) // c.log(cat_gifs) let gifItems = cat_gifs.map( (gif) => { return JSON.stringify( {"type": "image", "url": gif} ) } ).join(", ") c.log(gifItems) // must be valid json (when included in {} // URL exports.endpoint = function(request, response) { response.end(` { "$jason": { "head": { "title": "Josefine" }, "body": { "sections": [{ "items": [ {"type": "label", "text": "mao"}, ${gifItems} ] }] } } } `); } // "miau"
Loading…

no comments

    sign in to comment