Created
March 28, 2019 09:16
-
-
Save krazyjakee/b16838e91befbad7f6f393f6c2bf73a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios'; | |
axios.get('/popular') | |
.then(res => { | |
console.log(res.data); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import apicalypse from 'apicalypse'; | |
const defaultConfig = { | |
method: 'POST', | |
baseURL: 'https://api-v3.igdb.com', | |
headers: { | |
'user-key': API_KEY, | |
accept: 'application/json', | |
}, | |
responseType: 'json', | |
timeout: 30000, | |
} | |
export default (config) => apicalypse(config || defaultConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage on the serverside | |
import igdb from './igdb'; | |
// An example express route | |
server.get( | |
'/popular', | |
async (req, res) => { | |
const response = await igdb() | |
.fields("name, popularity") | |
.where('popularity != null & themes != (42) & version_parent = null') | |
.sort('popularity', 'desc') | |
.limit(20) | |
.request('/games'); | |
res.json(response.data); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment