Skip to content
Jacob Jordan edited this page Aug 18, 2016 · 1 revision

Methods

  • getGame(options, callback)
  • getGames(options, callback)

Examples

Single Resource

gb.getGame(
	{ 
		id: 3579,
		fields: ['name', 'platforms']
	}, 
	function(error, reponse, json){
		if(!error  && reponse.statusCode == 200){
			console.log(json.results.name + ' is available on:');
			json.results.platforms.forEach(platform =>{
				console.log('\t' + platform.name);
			});
		}
	}
);

Outputs:

Dragon Quest VIII: Journey of the Cursed King is available on:
        PlayStation 2
        iPhone
        Nintendo 3DS
        Android
        Nintendo 3DS eShop

Multiple Resources

gb.getGames(
	{ 
		limit: 5,
		offset: 21778,
		fields: ['name', 'platforms']
	}, 
	function(error, reponse, json){
		if(!error  && reponse.statusCode == 200){
			json.results.forEach(game =>{
				console.log(`${game.name} is available on ${game.platforms.length + (game.platforms.length > 1 ? ' platforms.' : ' platform.')}`);
			});
		}
	}
);

Outputs:

StarCraft II: Heart of the Swarm is available on 2 platforms.
StarCraft II: Legacy of the Void is available on 2 platforms.
Dreamfall Chapters is available on 4 platforms.
Blast Lacrosse is available on 1 platform.
Ichigo Mashimaro is available on 1 platform.

Clone this wiki locally