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

322
Views
POST http://localhost:3001/[object%20Promise] 404 (Not Found) React Axios

Here is my code to send data to the server but I always get this Error.

let data = {
        "email": "test@gmail.com",
        "language": "en",
        "country": "en",
        "istestentry": false
    };

    let jsonData = JSON.stringify(data);
    let encodedData = encodeURIComponent(jsonData);
    let url = "https://example.org/b/receiver/external";
    let fetchUrl = url + "?datajsonstr=" + encodedData + "&_=" + (new Date()).valueOf();
    let datafetch = fetch(fetchUrl);

    const [fetchedData, setFetchedData] = useState('');

    async function fetchData(){
        const  {data} = await axios.post(
            datafetch
        )
        setFetchedData(data)
    }

    useEffect(() => {
        fetchData()
    }, [])

    const handleSubmit = (event) => {
        event.preventDefault();
        fetchData()
};

I don't know how to solve this problem.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You are trying to send a promise instead of a stringified data. let datafetch = fetch(fetchUrl); gives you a promise. Also sending data through params is done with get requests. So I assume that you may need to make a get request:

let fetchUrl = url + "?datajsonstr=" + encodedData + "&_=" + (new Date()).valueOf();

const [fetchedData, setFetchedData] = useState('');

async function fetchData(){
    const  {data} = await axios.get(fetchUrl)
    setFetchedData(data)
}

(P.S. get or post depends on how your api handles requests. You can choose the correct one)

about 4 years ago · Juan Pablo Isaza Report

0

I solved it like this. if you don't want to use Axios, you can solve it also like this.

const [dataDone, setDataDone] = useState(false);

useEffect(() => {
    let data = {
        "email": "test@gmail.at",
        "language": "de",
        "country": "de",
        "istestentry": false
    };

    let jsonData = JSON.stringify(data);
    let encodedData = encodeURIComponent(jsonData);
    let url = "https://org.com;
    let fetchUrl = url + "?datajsonstr=" + encodedData + "&_=" + (new 
    Date()).valueOf();
    let datafetch = fetch(fetchUrl);

    datafetch.then(data => {
        setDataDone(true)
    })
}, [])
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!