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

440
Views
Failed to axios('localhost/something')

I was suffering with a cor error, than I tried to install cors and also did a app.use(cors()). Then I was suffering a new error, it was looking like to be a Axios error. https://imgur.com/a/aIalZQL

React code on front-end

import axios from 'axios'
import React,{useEffect, useState} from 'react'

export function App() {

  const [people, setPeople] = useState({})
  
  useEffect(() => {
    const getData = async() => {
      const result = await axios('http://localhost:3000/api/people')
      console.log('result of axios', result)
      return result
    }
    setPeople(getData())
  }, [])

  console.log('people', people)

  return (
    <div>
      hallo
    </div>    
  )
}

Nodejs back-end

const express = require('express')
const api = express()
const port = 3000;

api.use(express.json())
api.use(cors())

const people = [
    { id: 1, nome: "João", idade: 20 },
    { id: 2, nome: "Maria", idade: 25 },
    { id: 3, nome: "José", idade: 30 }
];

const routes = {
    '/api/people': 'List people',
}

api.get("/", (req, res) => {
    res.json(routes)
})

api.get("/api/people", (req, res) => {
    console.log(req)
    res.json(people)
})

api.listen(port, () => {
    console.log(`api running`)
})

New error

about 4 years ago · Juan Pablo Isaza
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!