简体   繁体   English

如何修复 AxiosError 中 node_modules\axios\lib\core\AxiosError.js:null 的网络错误

[英]How To Fix The Error For the Network Error at node_modules\axios\lib\core\AxiosError.js:null in AxiosError

When i Call The API For User Creating using React Native, Get an Error and no any Response on click and no any data print on console...当我为使用 React Native 创建的用户调用 API 时,出现错误,单击时没有任何响应,控制台上也没有任何数据打印...

we get the error like我们得到这样的错误

Network Error at node_modules\axios\lib\core\AxiosError.js:null in AxiosError at node_modules\axios\lib\adapters\xhr.js:null in handleError at node_modules\event-target-shim\dist\event-target-shim.js:null in EventTarget.prototype.dispatchEvent at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:null in setReadyState at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:null in __didCompleteResponse at node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:null in emit at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __callFunction at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __guard$argument_0 at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in __guard at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null in callFunctionReturnFlushedQueue node_modules\axios\lib\core\AxiosError.js 中的网络错误:null .js:null 在 EventTarget.prototype.dispatchEvent 在 node_modules\react-native\Libraries\Network\XMLHttpRequest.js:null 在 setReadyState 在 node_modules\react-native\Libraries\Network\XMLHttpRequest.js:null -native\Libraries\vendor\emitter\EventEmitter.js:null 在 node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null 在 node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js 的 __callFunction 中发出:88634815在 __guard$argument_0 在 node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null 在 __guard 在 node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:null 在 callFunctionReturnFlushedQueue

import { View, Text, TextInput, Button, StyleSheet } from "react-native";
import React from "react";
import { Formik } from "formik";
import * as yup from "yup";
import axios from "axios";


const initialValue = {
  name: "",
  email: "",
  password: "",
};

const validationSchema = yup.object({
  name: yup
    .string()
    .trim()
    .required("Name is Missing"),
  email: yup
    .string()
    .email("Invalide Email ")
    .required("Email is Missing "),
  password: yup
    .string()
    .trim()
    .required("Password is Missing")
    .min(8, "Password is too Short!"),

  repassword: yup.string().required("Re-Password is Missing !"),
});

const handleSignup = async (values, formikActions) => {
  try {
    const {data} = await axios.post("http//:192.168.0.103:4000/register", {
      ...values,
    }); 
    console.log(data);
    formikActions.resetForm();
    formikActions.setSubmitting(false);
  } catch (error) {
    console.log(error);
  }
};
const SignupScreen = (props) => {
  return (
    <Formik
      initialValues={initialValue}
      validationSchema={validationSchema}
      onSubmit={handleSignup}
    >
      {({
        errors,
        values,
        touched,
        handleBlur,
        handleChange,
        handleSubmit,
      }) => {
        // console.log(errors, values);
        return (
          <>
            <View style={aicaas.container}>
              <Text style={{ fontSize: 22, color: "grey" }}>
                User Registration
              </Text>
              <View style={aicaas.inputcontainer}>
                <Text style={{ color: "red" }}>
                  {touched.name && errors.name ? errors.name : ""}
                </Text>
                <TextInput
                  style={aicaas.input}
                  onChangeText={handleChange("name")}
                  value={values.name}
                  onBlur={handleBlur("name")}
                  placeholder="Name"
                />
              </View>
              <View style={aicaas.inputcontainer}>
                <Text style={{ color: "red" }}>
                  {touched.email && errors.email ? errors.email : ""}
                </Text>
                <TextInput
                  style={aicaas.input}
                  onChangeText={handleChange("email")}
                  keyboardType="email-address"
                  value={values.email}
                  placeholder="Email"
                />
              </View>
              <View style={aicaas.inputcontainer}>
                <Text style={{ color: "red" }}>
                  {touched.password && errors.password ? errors.password : ""}
                </Text>
                <TextInput
                  style={aicaas.input}
                  onChangeText={handleChange("password")}
                  value={values.password}
                  placeholder="Password"
                  secureTextEntry={true}
                />
              </View>
              <View style={aicaas.inputcontainer}>
                <Text style={{ color: "red" }}>
                  {touched.repassword && errors.repassword
                    ? errors.repassword
                    : ""}
                </Text>
                <TextInput
                  style={aicaas.input}
                  onChangeText={handleChange("repassword")}
                  value={values.repassword}
                  placeholder="Re-Password"
                />
              </View>
              <View style={aicaas.inputcontainer}>
                <Button onPress={handleSubmit} title="Register" />
              </View>
            </View>
          </>
        );
      }}
    </Formik>
  );
};

const aicaas = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
  },
  input: {
    borderWidth: 2,
    borderRadius: 5,
    height: 50,
    borderColor: "grey",
    marginTop: 10,
    backgroundColor: "whitesmoke",
    paddingHorizontal: 10,
    fontSize: 20,
  },
  inputcontainer: {
    width: "80%",
    marginTop: 20,
  },
});

export default SignupScreen;

I think the error is from the endpoint http//:192.168.0.103:4000/register .我认为错误来自端点http//:192.168.0.103:4000/register

It should be http://192.168.0.103:4000/register应该是http://192.168.0.103:4000/register

ie http:// not http//:http://不是http//:

暂无
暂无

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

相关问题 ./node_modules/axios/lib/adapters/http.js 中的错误 - ERROR in ./node_modules/axios/lib/adapters/http.js 反应原生错误:node_modules/axios/lib/core/createError.js:16:24 in createError - react native error: node_modules/axios/lib/core/createError.js:16:24 in createError 未处理的 Promise 拒绝:AxiosError:网络错误 - Unhandled Promise Rejection: AxiosError: Network Error ../node_modules/axios/lib/helpers/cookies.js [1] 错误:EPERM:不允许操作,读取 - ../node_modules/axios/lib/helpers/cookies.js [1] Error: EPERM: operation not permitted, read AxiosError {消息:'网络错误',名称:'AxiosError',代码:'ERR.NETWORK',配置:{...},请求:XMLHttpRequest,...} - AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …} AxiosError:React Native 在向本地后端发出 api 请求时出现网络错误 - AxiosError: Network Error in React Native on making api request to local backend 如何修复“模块构建失败(来自 ./node_modules/babel-loader/lib/index.js):”? - How to fix "Module build failed (from ./node_modules/babel-loader/lib/index.js):"? 如何解决未捕获的错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js): - How to Solve Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js): 如何修复错误“编译失败:./node_modules/@react-leaflet/core/esm/path.js 10:41 模块解析失败:意外令牌 (10:41)” - How to fix error "Failed to compile : ./node_modules/@react-leaflet/core/esm/path.js 10:41 Module parse failed: Unexpected token (10:41)" 如何解决 React 错误模块构建失败(来自 ./node_modules/babel-loader/lib/index.js): - how to resolve React error Module build failed (from ./node_modules/babel-loader/lib/index.js):
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM