Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

328
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda