Skip to content

Instantly share code, notes, and snippets.

@krazyjakee
Created March 28, 2019 09:16
Show Gist options
  • Save krazyjakee/b16838e91befbad7f6f393f6c2bf73a9 to your computer and use it in GitHub Desktop.
Save krazyjakee/b16838e91befbad7f6f393f6c2bf73a9 to your computer and use it in GitHub Desktop.
import axios from 'axios';
axios.get('/popular')
.then(res => {
console.log(res.data);
});
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);
// 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