Created
June 17, 2015 04:09
-
-
Save hellobrian/44ff44334ffa8b9566ae to your computer and use it in GitHub Desktop.
PUT request for pokemon.js
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 characters
| 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