Fetch by Samuel-Drei · Pull Request #459 · javascript-tutorial/pt.javascript.info
Repository navigation
Fetch - #459
Open
Samuel-Drei wants to merge 6 commits into javascript-tutorial:master from Samuel-Drei:master
Open
Fetch #459 Samuel-Drei wants to merge 6 commits into javascript-tutorial:master from Samuel-Drei:master
Conversation
Samuel-Drei commented May 13, 2026
Copy link Copy Markdown
No description provided.
Fetch
cd2b8fc
CLAassistant commented May 13, 2026 · edited Loading
Copy link Copy Markdown
|
|
View reviewed changes
gabifs left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Valeu pela tradução, Samuel! O texto ficou muito bom -- identificadores preservados, links info: mantidos, marcadores *!* intactos e o callout warn aninhado correto.
Só tem um bloqueante: as cercas de código do artigo foram trocadas de ``` para ````. Deixei o detalhe inline. Fora isso, três ajustes de consistência e dois nits.
Samuel-Drei and others added 5 commits September 7, 2026 13:36
Update 5-network/01-fetch/article.md
2835e89
Co-authored-by: Gabriel Fernandes <ga3riel.fernandess@gmail.com>
Update 5-network/01-fetch/article.md
48d25c9
Co-authored-by: Gabriel Fernandes <ga3riel.fernandess@gmail.com>
Update 5-network/01-fetch/article.md
7acc93e
Co-authored-by: Gabriel Fernandes <ga3riel.fernandess@gmail.com>
Update 5-network/01-fetch/article.md
b38d22b
Co-authored-by: Gabriel Fernandes <ga3riel.fernandess@gmail.com>
Update 5-network/01-fetch/article.md
c385fbe
Co-authored-by: Gabriel Fernandes <ga3riel.fernandess@gmail.com>wesleysilva02 reviewed Sep 15, 2026
View reviewed changes
wesleysilva02 left a comment
Copy link Copy Markdown
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Muito bom
nazarepiedady commented Nov 10, 2026
Copy link Copy Markdown
Member
|
@gabifs que achas das alterações? |
gabifs commented Nov 10, 2026
Copy link Copy Markdown
Contributor
|
@nazarepiedady @Samuel-Drei durante a tradução foram alteradas as marcações de bloco de código (```), de 3 para 4 (````). Isso pode quebrar a renderização do markdown |
View reviewed changes
gabifs left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Oi @Samuel-Drei ! Obrigado pelas atualizações desde a última revisão. A tradução está boa: fiel, natural e sem trechos faltando.
O que falta antes do merge:
- Cercas de código : continuam com quatro crases. Deixei uma sugestão por bloco, e dá para aplicar todas de uma vez (Files changed → "Add suggestion to batch" → "Commit suggestions").
- Terminologia : "headers" → "cabeçalhos" e "body" → "corpo", para alinhar com os outros artigos de
5-network. Aqui eu errei na revisão anterior, quando sugeri "headers". Desculpa!
O resto são sugestões opcionais. Detalhe: os três arquivos .md terminam sem quebra de linha no fim, e vale manter como no original.
| ``` ` js | ||
| let promise = fetch(url, [options]) | ||
| ``` | ||
| ``` ` |
| ``` ` js | ||
| let response = await fetch(url); | ||
|
|
||
| if (response.ok) { // if HTTP- status is 200-299 | ||
| // get the response body (the method explained below ) | ||
| if (response.ok) { // se o status HTTP estiver entre 200-299 | ||
| // obtém o body da resposta (o método é explicado abaixo ) | ||
| let json = await response.json(); | ||
| } else { | ||
| alert("HTTP-Error: " + response.status); | ||
| } | ||
| ``` | ||
| ``` ` |
| ``` ` js run async | ||
| let url = 'https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits'; | ||
| let response = await fetch(url); | ||
|
|
||
| *!* | ||
| let commits = await response.json(); // read response body and parse as JSON | ||
| let commits = await response.json(); // lê o body da resposta e interpreta como JSON | ||
| */!* | ||
|
|
||
| alert(commits[0].author.login); | ||
| ``` | ||
| ``` ` |
| ``` ` js run | ||
| fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits') | ||
| .then(response => response.json()) | ||
| .then(commits => alert(commits[0].author.login)); | ||
| ``` | ||
| ``` ` |
| ``` ` js run async | ||
| let response = await fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits'); | ||
|
|
||
| let text = await response.text(); // read response body as text | ||
| let text = await response.text(); // lê o body da resposta como texto | ||
|
|
||
| alert(text.slice(0, 80) + '...'); | ||
| ``` | ||
| ``` ` |
| let result = await response.json(); | ||
| alert(result.message); | ||
| ``` | ||
| ``` ` |
| Neste exemplo, há um `<canvas>` onde podemos desenhar movendo o mouse sobre ele. Um clique no botão "Submit" envia a imagem ao servidor : | ||
|
|
||
| ```html run autorun height="90" | ||
| ``` ` html run autorun height="90" |
| </script> | ||
| </body> | ||
| ``` | ||
| ``` ` |
| A função `submit()` pode ser reescrita sem `async/await` assim : | ||
|
|
||
| ```js | ||
| ``` ` js |
| }, 'image/png'); | ||
| } | ||
| ``` | ||
| ``` ` |