2
respostas

Erro para mostrar os dados da api

Na aula 3 segui todos os passos mencionados nos ultimos dois sub-topicos da aula, que são o mão na massa. Instalei tudo e fiz tudo que precisava. Utilizo o Debian 9. O que ocorre é que mesmo eu copiando todo arquivo app.js da aula, ainda sim permanece esse erro, ou seja, os dados não aparecem na página, fica tudo vazio. No terminal me retorna o seguinte:

Compiled with warnings.

./src/App.js
  Line 38:  The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
  Line 41:  The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
  Line 42:  The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
  Line 43:  The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

Já no console me retorna:

0.chunk.js:35369 Download the React DevTools for a better development experience: https://fb.me/react-devtools
main.chunk.js:128 render
VM25:37 Warning: Failed prop type: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.
    in input (at App.js:59)
    in div (at App.js:57)
    in form (at App.js:56)
    in div (at App.js:55)
    in div (at App.js:54)
    in div (at App.js:50)
    in div (at App.js:29)
    in App (at src/index.js:7)
window.console.error @ VM25:37
main.chunk.js:113 didMount
:8080/api/autores:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
localhost/:1 Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.
0.chunk.js:14107 ./src/App.js
  Line 38:  The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
  Line 41:  The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
  Line 42:  The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
  Line 43:  The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
printWarnings @ 0.chunk.js:14107
0.chunk.js:14052 The development server has disconnected.
Refresh the page if necessary.

Gostaria de ajuda. Obrigado

2 respostas

Pelo que eu vi de suas mensagens de erro, o problema está aqui:

:8080/api/autores:1 Failed to load resource: net::ERR_CONNECTION_REFUSED

Pelo erro, ele não está conseguindo acesso a API.

Se esta API que você está utilizado é local, verifique se você iniciou antes de usar o React, e se você consegue acessar diretamente (ou pelo navegador ou usando alguma ferramenta como o Postman)

Como assim iniciou antes de usar o React e acessar diretamente ?