Javascript 来自本地主机的Axios Post请求发出400错误请求错误
我第一次使用Axios时,我在React Redux应用程序中努力获得响应: 请求是:Javascript 来自本地主机的Axios Post请求发出400错误请求错误,javascript,ajax,post,http-status-code-404,axios,Javascript,Ajax,Post,Http Status Code 404,Axios,我第一次使用Axios时,我在React Redux应用程序中努力获得响应: 请求是: export default function signUp(username, password) { let settings = { url: "https://api.example.com/signup", data: { "Username" : username, "Password" : password }, metho
export default function signUp(username, password) {
let settings = {
url: "https://api.example.com/signup",
data: {
"Username" : username,
"Password" : password },
method: 'POST',
headers : {
"Content-Type" : "application/json"
},
transformRequest: [(data) => {
return JSON.stringify(data);
}]
};
return ( dispatch ) => {
dispatch( signUpRequest());
console.log( "%c settings are...", "color : white", settings );
axios( settings ).then(
( response ) => {
console.log( "%c and the response is...", "color : blue", response );
}
).catch(
( response ) => {
console.log( "%c and the error is...", "color : pink", response );
}
);
};
}
我得到一个404错误-未找到。上面的url
(为隐私而编辑)应该是正确的。还有什么我做错的吗?这可能是本地主机的问题吗?如何检查/测试
编辑:前面提到的标题不正确。我得到以下信息:
根据屏幕截图,您实际收到了400个错误请求(不是您描述的404),这意味着服务器拒绝是有原因的。根据屏幕截图,您实际收到了400个错误请求(不是您描述的404),这意味着服务器拒绝是有原因的。