gatsby-source-pokemons
Version:
A gatsby source plugin for building Pokemon Projects using GraphQL in Gatsby.
16 lines (14 loc) • 489 B
JavaScript
const fs = require("fs");
const { results } = require("./pokemons.json");
let res = results.map(result => {
const { hp, attack, defense, sp_atk, sp_def, speed, national_number } = result
result.natl_num = Number(national_number)
result.total = hp + attack + defense + sp_atk + sp_def + speed;
return result;
})
fs.writeFile("pokemonsv2.json", JSON.stringify(res), function (
err
) {
if (err) throw err;
console.log(success(`finished!`));
});