Created
March 28, 2019 09:16
-
-
Save krazyjakee/b16838e91befbad7f6f393f6c2bf73a9 to your computer and use it in GitHub Desktop.
Revisions
-
krazyjakee created this gist
Mar 28, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ import axios from 'axios'; axios.get('/popular') .then(res => { console.log(res.data); }); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ 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 hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ // 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); } );