admin管理员组文章数量:1323715
I am creating a ReactJS and NodeJS application. While authenticating my user on route 'localhost:5000/user/signup' Internal server error with code 500 is received. For authenticating my user , I am using this auth.js file
import * as api from '../api'
export const signup=(authData,navigate)=>async(dispatch)=>{
try {
const response=await api.signUp(authData)
let data=response.data;
dispatch({type:"AUTH", data})
navigate('/')
} catch (error) {
console.log(error)
}
}
Here, on line 5 , authdata is where I think the error is. Maybe axios data format for response or something. The signUp function is as follows:
import axios from 'axios'
const API=axios.create({baseURL:'http://localhost:5000'})
export const signUp=(authData)=>API.post('/user/signup',authData,{headers:{"Content-Type" : "application/json"}})
And the function call is set from a form submit button, whose code snippet is as follows: The code snippet includes the format of data which I am passing.
let data=JSON.stringify({
name:name,
email:email,
password:password
});
dispatch(signup(data),navigate)
The error is something like this, everytime I click on submit button:
AxiosError {message: 'Request failed with status code 500', name: 'AxiosError', code: 'ERR_BAD_RESPONSE', config: {…}, request: XMLHttpRequest, …}
code
:
"ERR_BAD_RESPONSE"
config
:
{transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …}
message
:
"Request failed with status code 500"
name
:
"AxiosError"
request
:
XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
response
:
{data: {…}, status: 500, statusText: 'Internal Server Error', headers: {…}, config: {…}, …}
[[Prototype]]
:
Error
I am creating a ReactJS and NodeJS application. While authenticating my user on route 'localhost:5000/user/signup' Internal server error with code 500 is received. For authenticating my user , I am using this auth.js file
import * as api from '../api'
export const signup=(authData,navigate)=>async(dispatch)=>{
try {
const response=await api.signUp(authData)
let data=response.data;
dispatch({type:"AUTH", data})
navigate('/')
} catch (error) {
console.log(error)
}
}
Here, on line 5 , authdata is where I think the error is. Maybe axios data format for response or something. The signUp function is as follows:
import axios from 'axios'
const API=axios.create({baseURL:'http://localhost:5000'})
export const signUp=(authData)=>API.post('/user/signup',authData,{headers:{"Content-Type" : "application/json"}})
And the function call is set from a form submit button, whose code snippet is as follows: The code snippet includes the format of data which I am passing.
let data=JSON.stringify({
name:name,
email:email,
password:password
});
dispatch(signup(data),navigate)
The error is something like this, everytime I click on submit button:
AxiosError {message: 'Request failed with status code 500', name: 'AxiosError', code: 'ERR_BAD_RESPONSE', config: {…}, request: XMLHttpRequest, …}
code
:
"ERR_BAD_RESPONSE"
config
:
{transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …}
message
:
"Request failed with status code 500"
name
:
"AxiosError"
request
:
XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
response
:
{data: {…}, status: 500, statusText: 'Internal Server Error', headers: {…}, config: {…}, …}
[[Prototype]]
:
Error
Share
Improve this question
edited Oct 3, 2022 at 11:01
VLAZ
29.1k9 gold badges63 silver badges84 bronze badges
asked Oct 3, 2022 at 10:53
Devansh ShahDevansh Shah
431 gold badge1 silver badge3 bronze badges
1
-
500 is server error, so you need to check with your backend team
本文标签: javascriptAxiosError on POST request is giving ERRBADRESPONSE on my ReactJS CodeStack Overflow
版权声明:本文标题:javascript - AxiosError on POST request is giving ERR_BAD_RESPONSE on my ReactJS Code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742125641a2421927.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论