Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic REST API with NodeJS and Express
const request = require('request')
const express = require('express')
const app = express()
app.get('/', (req, res) => {
if (!req.query.search) {
return res.send('Please provide a search string...')
}
const url = 'http://api.giphy.com/v1/gifs/search?q=' + encodeURIComponent(req.query.search) + '&api_key=YOUR_API_KEY'
request( { url, json: true }, (error, {body}) => {
if (error) {
return res.send('Unable to connect.')
}
res.send(body)
})
})
app.listen(3000, () => {
console.log('Server is up!')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.