Saltar al contenido

Ejemplo de código de reacción axios post 500 (error interno del servidor)

Nuestro team redactor ha estado por horas investigando la respuesta a tu interrogante, te compartimos la solución y deseamos resultarte de gran apoyo.

Ejemplo 1: reaccionar js http post 500 error interno del servidor

exportdefaultfunctioncallApi2(endpoint, method ='GET', body){let headers ='content-type':'application/json'console.log(body);returnaxios(
    method: method,
    url:`$Config.API_URL2/$endpoint`,
    data:JSON.stringify(body),
    headers:'content-type':'application/json',).catch(err=>console.log(err););

Ejemplo 2: POST http: // localhost: 5001 / api / v1 / identity / login 500 (Error interno del servidor) LoginForm.jsx: 30 Error: La solicitud falló con el código de estado 500 en createError (createError.js: 16) en asentar ( asentar.js: 17) en XMLHttpRequest.handleLoad (xhr.js: 61) reaccionar

axios.post(
            config.apiGateway.URL+".../signin",
            payload
        ).then(response=>console.log(response)if(response.status==200)console.log("Login successfull");this.setState(token: response.data.JWT_TOKEN);elseconsole.log(response.status)this.setError()).catch(error=>this.setError()console.log(error)if(error.response)console.log("--------------------------------------------------")// The request was made and the server responded with a status code// that falls out of the range of 2xxconsole.log(error.response.data);console.log(error.response.status);console.log(error.response.headers);elseif(error.request)console.log("*************************")// The request was made but no response was received// `error.request` is an instance of XMLHttpRequest in the browser and an instance of// http.ClientRequest in node.jsconsole.log(error.request);elseconsole.log("++++++++++++++++++++++++")// Something happened in setting up the request that triggered an Errorconsole.log('Error', error.message);console.log(error.config);)

Ejemplo 3: reaccionar js http post 500 error interno del servidor

res.header('Access-Control-Allow-Origin','*');
 res.header('Access-Control-Allow-Headers','Content-Type');
 res.header('Access-Control-Allow-Methods','GET, POST, PATCH, PUT, DELETE, OPTIONS');

Te mostramos reseñas y calificaciones

Si te gustó nuestro trabajo, puedes dejar una noticia acerca de qué te ha gustado de este post.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *