ios - 反应原生 iOS - JSON VALUE '' nsnull 类型的 ' 不能转换为有效的 url
问题描述
每次我在插入新邮件和密码后通过 expo 注册应用程序时,都会看到此屏幕。 这是屏幕错误
即使在我关闭博览会结束后再次打开它也会显示相同的红色屏幕和消息。但是,如果我关闭项目(通过摇动刷新它)并再次进入整个项目,现在有了一个现有的用户,它到目前为止工作得很好......(仍然需要修复)。
这是 **Register.js页面代码:**
import React, { Component } from "react";
import { View, Button, StyleSheet, TextInput, Alert, AsyncStorage } from "react-native";
const URL = 'http://185.60.170.14/plesk-site-preview/ruppinmobile.ac.il/site17/WebService.asmx';
export default class Register extends Component {
state = {
email: "",
password: "",
repassword: ""
};
Register = () => {
if(this.state.password != this.state.repassword){
Alert.alert(
"Error",
'Password does not match',
[{ text: "OK", onPress: () => null }],
{ cancelable: false }
);
this.setState({password: '', repassword: ''});
return;
}
let data = {
email: this.state.email,
password: this.state.password
};
fetch(URL + "/Register", {
// בקשה לשרת למתודה Register
body: JSON.stringify(data), // שליחת פרמטרים
method: "POST",
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(res => {
return res.json();
})
.then(userData => {
console.log(userData.d);
if (userData.d == "Error: This email is already in use") {
Alert.alert(
"Error",
userData.d,
[{ text: "OK", onPress: () => null }],
{ cancelable: false }
);
} else {
AsyncStorage.setItem("@KnowingFriends:user", userData.d);
this.props.navigation.navigate("MainApp");
}
})
.catch(err => {
console.error(err);
});
};
render() {
return (
<View style={styles.container}>
<TextInput
style={styles.input}
onChangeText={text => this.setState({ email: text })}
value={this.state.email}
placeholder="Email"
/>
<TextInput
style={styles.input}
onChangeText={text => this.setState({ password: text })}
value={this.state.password}
secureTextEntry={true}
placeholder="Password"
/>
<TextInput
style={styles.input}
onChangeText={text => this.setState({ repassword: text })}
value={this.state.repassword}
secureTextEntry={true}
placeholder="Repeat Password"
/>
<Button onPress={this.Register} title="Submit" color="#841584" />
<Button
onPress={() => {
this.props.navigation.navigate("Login");
}}
title="Go back"
color="#841584"
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
input: {
height: 40,
width: 300,
borderColor: "gray",
borderWidth: 1
}
});
我该如何解决这个问题?
解决方案
我也有同样的问题,但我修复了
state = {
text: '',
image: null,
};
改变了
state = {
text: '',
image: '',
};
推荐阅读
- c# - 未从 C# 中的 FirebaseAdminSK 接收推送通知到 ios
- r - fable::ARIMA 在以编程方式生成公式时找不到 xreg
- javascript - 如何将 Storybook 配置为从项目根目录以外的目录运行
- salesforce - 工作台未正确创建 CSV 文件
- batch-file - 使用 mp4box 将音频添加到多个 mp4 文件
- python - 如何从字典中获取第二大值的第一个键?
- r - 使用 `case_when` 和 %in% 汇总 R 中的多个列
- mysql - 在 MySQL CONVERT_TZ 中处理夏令时
- java - 是否可以在 Java 的编译时接收子类的名称?
- javascript - 使每个元素在 div 元素的中心