Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!