来自LocalHost的Axios发布请求发出400错误请求错误

时间:2017-01-13 00:28:54

标签: 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 },
      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(为隐私而编辑)应该在上面正确。还有什么我做错了吗?这可能是localhost的问题吗?我该如何检查/测试?

编辑:提到的上一个标题不正确。我得到以下内容:

enter image description here

0 个答案:

没有答案