Skip to content

Instantly share code, notes, and snippets.

@hellobrian
Created June 17, 2015 04:09
Show Gist options
  • Select an option

  • Save hellobrian/44ff44334ffa8b9566ae to your computer and use it in GitHub Desktop.

Select an option

Save hellobrian/44ff44334ffa8b9566ae to your computer and use it in GitHub Desktop.
PUT request for pokemon.js
var request = require('request');
var fs = require('fs');
var pokemonjson = require('./pokemon.json');
var Pokemon = require('./app/models/pokemon.js');
// db.pokemons.update({}, {$unset: {sprites: ""}}, {multi: true, safe: true});
for (var i=600; i < 718; i++) {
var typesArray = [];
var spriteUrl = 'http://pokeapi.co/media/img/'+ pokemonjson[i].national_id +'.png';
if (pokemonjson[i].types[0] !== undefined) {
typesArray.push(pokemonjson[i].types[0].name);
}
if (pokemonjson[i].types[1] !== undefined) {
typesArray.push(pokemonjson[i].types[1].name);
}
console.log('id:', i, typesArray);
request({
url: 'http://localhost:8080/api/pokemon/' + pokemonjson[i].name,
method: 'PUT',
json: {
types: typesArray,
image_url: spriteUrl
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment