简体   繁体   English

Axios 请求失败,状态码为 404 - React Native

[英]Axios Request failed with status code 404 - React Native

I am trying to send data to my Google Cloud server.我正在尝试将数据发送到我的 Google Cloud 服务器。 (login form). (登录表格)。 I have an error,我有一个错误,

[Error: Request failed with status code 404] [错误:请求失败,状态码为 404]

I also tried fetch method, but I got a network failed error there.我也尝试了 fetch 方法,但我在那里遇到了网络失败错误。

This is my code:这是我的代码:

handleLoginUser(){
const data = new FormData();
  data.append('email', 'aaykgxr@gmail.com');
  data.append('password', '1234567890');

  return axios.post('http://*serverip*/users/login',
    data,
    {
      headers: {
        'Content-Type': 'application/json',
      }
    },
  )
  .then(function (response) {
          console.log(response);
      })
      .catch(function (response) {
          console.log(response);
      });
}

Thanks for your help.谢谢你的帮助。

如果您使用 formdata,您应该使用其他一些内容类型:

'Content-type':'multipart/form-data'

'http:// serverip /users/login.json()....dot json() 丢失

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 请求失败,状态码为500 React Native - Request failed with status code 500 React Native 尝试访问 zomato 搜索 (axios) 时收到“请求失败,状态代码:404” - Getting a 'Request failed with status code:404' when trying to access zomato search (axios) React-Native (Android):请求失败,状态码为 403 - bscscan api testnet - React-Native (Android) : Request failed with status code 403 - bscscan api testnet Nativescript-Vue & Axios 工作 function 导致“错误:请求失败,状态码 429” - Nativescript-Vue & Axios working function result in “Error: Request failed with status code 429” Nativescript-Vue axios 在本地 laravel API 上调用错误 [Request failed with status code null] - Nativescript-Vue axios call error on local laravel API [Request failed with status code null] Axios 承诺处理 - 在 react-native 中获取“可能未处理的承诺拒绝 - 类型错误:网络请求失败” - Axios Promise Handling - Getting “Possible Unhandled Promise Rejection - TypeError: Network request failed” in react-native React Native 0.66.* axios 调用 [TypeError: Network request failed] ANDROID - React Native 0.66.* axios call [TypeError: Network request failed] ANDROID React Native FlatList 不渲染 Axios API 请求 - React Native FlatList is not rendring an Axios API request React Native:网络请求失败 - React Native : Network request failed 反应本机提取请求失败 - React native fetch request failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM