Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
Data not fetching with custom url axios ReactJs

i am new in Reactjs and working on nextjs,I have following components (components/Trending.js) which is working with this url "https://jsonplaceholder.typicode.com/users" but whenever i changed url(My custom url which contaning api data) to "https://90d9-2405-201-5002-215b-6c7b-1f41-7a19-f145.in.ngrok.io/serges/api/blogs" then records is not fetching,Here is my code (components/Trending.js)

import React from 'react';
class Trending extends React.Component {
    state = {
        trending: []
      }
    componentDidMount() {
        axios.get('https://90d9-2405-201-5002-215b-6c7b-1f41-7a19-f145.in.ngrok.io/serges/api/blogs',
        )
          .then(res => {
            const trending = res.data;
            this.setState({ trending });
          })
      }
    render() {
      return (
        <div>
          <table className="table table-hover">
              {this.state.trending.map((post, index) => {
                 return (
                      <tr>
                      <td>
                          <h4>{post.name}</h4>
                      </td>
                      </tr>
                  )
              })}
          </table>
        </div>
      );
    }
  }

  export default Trending;
  import axios from 'axios';
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

I think you need to import Axios at the top of the file.

about 4 years ago · Juan Pablo Isaza Relatório

0

You need to check your browser's console and Network tab. Most probably it's the CORS issue

about 4 years ago · Juan Pablo Isaza Relatório

0

This is a CORS issue. You should fix it on the server-side. Add the front-end application URL in the 'Access-Control-Allow-Origin' response header. For local development, you can create a proxy server.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda