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
// requisição: | |
// adicionar um novo endereço de e-mail à minha conta do GitHub | |
fetch('https://api.github.com/user/emails', { // URI | |
method: 'POST', // método | |
body: JSON.stringify(["[email protected]"]) // corpo | |
}) | |
.then(response => { | |
// recebemos a resposta e logamos o status | |
console.log(response.status) | |
// retorna o corpo em formato JSON |
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
// requisição: | |
// não é preciso informar o método (GET é o padrão), | |
// nem cabeçalho ou corpo (requisição GET não precisa de corpo) | |
fetch('https://api.github.com/repos/facebook/react/releases/latest') // URI | |
.then(response => { | |
// recebemos a resposta e logamos o status | |
console.log(response.status) | |
// retorna o corpo da resposta em formato JSON | |
return response.json() | |
}) |
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
// the request: | |
// try to GET an nonexistent URI | |
fetch('https://api.github.com/nonexistent-uri') | |
.then(response => { | |
if (response.ok) { | |
// we should not reach here | |
console.log('success') | |
} else { | |
console.log(response.status) | |
} |
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
// the request: | |
// POST a new email address to my GitHub account | |
fetch('https://api.github.com/user/emails', { // the URI | |
method: 'POST', // the method | |
body: JSON.stringify(["[email protected]"]) // the body | |
}) | |
.then(response => { | |
// we received the response and print the status code | |
console.log(response.status) | |
// return response body as JSON |
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
// the request: | |
// GET information about the latest React release on GitHub | |
// we don't need to inform the method (GET is the default), | |
// headers or body (GET request doesn't need one) | |
fetch('https://api.github.com/repos/facebook/react/releases/latest') // the URI | |
.then(response => { | |
// we received the response and print the status code | |
console.log(response.status) | |
// return response body as JSON | |
return response.json() |
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
const path = require('path') | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.resolve('dist'), | |
filename: 'bundle.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
import React from 'react' | |
import './icons.svg' | |
const Icon = (props) => ( | |
<svg className={`icon icon-${props.name}`}> | |
<use xlinkHref={`#icons_${props.name}`} /> | |
</svg> | |
) | |
export default Icon |
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
// criar uma função que recebe uma lista de alunos | |
// e loga (console.log) se o aluno foi aprovado, | |
// ou o motivo da reprovação. Ex: | |
// Fulano foi aprovado(a) | |
// Fulano foi reprovado(a) por nota | |
// Fulano foi reprovado(a) por faltas | |
// OBS.: Critérios de aprovação: nota maior ou igual a 6 e | |
// faltas menor que 25% do total de aulas | |
var totalAulas = 30; |
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
class UserListContainer extends React.Component { | |
... | |
toggleActive (event) { | |
// event logic | |
} | |
render () { | |
return ( | |
<UserList users={this.state.users} toggleActive={this.toggleActive} /> |
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
const UserList = (props) => { | |
return ( | |
<ul> | |
{props.users.map(user => <li key={user.id}>{user.name}</li>)} | |
</ul> | |
); | |
}; |