This file contains 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
1. Run tsc --init in your project folder to create tsconfig.json file (if you don't have one already). | |
2. Press Ctrl+Shift+B to open a list of tasks in VS Code and select tsc: watch - tsconfig.json. | |
3. Done! Your project is recompiled on every file save. | |
You can have several tsconfig.json files in your workspace and run multiple compilations at once if you want (e.g. frontend and backend separately). |
This file contains 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
module.exports = { | |
apiUrl: 'https://breaking-bad-voting.herokuapp.com/graphql', | |
queries: { | |
getCharacters: `{ | |
characters { | |
id | |
name | |
actor | |
total_episodes | |
} |
This file contains 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
const axios_ = require('axios'); | |
const apiUrl = require('./../constants').apiUrl; | |
const queries = require('./../constants').queries; | |
axios_.post(apiUrl, { | |
query: queries.getCharacters | |
}) | |
.then((res) => { | |
console.log('--------------------- Lista de Personajes --------------------------') | |
console.log(res.data) |
This file contains 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
iMac-de-Anartz:queries anartz$ node axios.js | |
--------------------- Lista de Personajes -------------------------- | |
{ data: | |
{ characters: | |
[ [Object], | |
[Object], | |
[Object], | |
[Object], | |
[Object], | |
[Object], |
This file contains 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
{ | |
"data": { | |
"characters": [ | |
{ | |
"id": "1", | |
"name": "Walter White", | |
"total_episodes": 62 | |
}, | |
{ | |
"id": "2", |
This file contains 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
--------------------- Lista de Personajes -------------------------- | |
[ { id: '1', | |
name: 'Walter White', | |
actor: 'Bryan Cranston', | |
total_episodes: 62 }, | |
{ id: '2', | |
name: 'Jesse Pinkman', | |
actor: 'Aaron Paul', | |
total_episodes: 62 }, | |
{ id: '3', |
This file contains 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
axios_.post(apiUrl, { | |
query: queries.getCharacterWalter | |
}) | |
.then((res) => { | |
console.log('--------------------- Información de Walter White - ID = 1 --------------------------') | |
console.log(res.data) | |
}) | |
.catch((error) => { | |
console.error(error) | |
}); |
This file contains 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
--------------------- Información de Walter White - ID = 1 -------------------------- | |
{ id: '1', name: 'Walter White', total_episodes: 62, votes: 164 } |
This file contains 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
{ data: | |
{ character: | |
{ id: '1', name: 'Walter White', total_episodes: 62, votes: 164 } } } |
This file contains 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
axios_.post(apiUrl, { | |
query: queries.getSelectCharacter, | |
variables: { id: '2'} | |
}) | |
.then((res) => { | |
const character = res.data.data.character; | |
console.log(`Personaje seleccionado ID ${character.id} - ${character.name}`) | |
console.log(character) | |
}) | |
.catch((error) => { |
OlderNewer