从状态中获取值时,Json.stringify无法序列化循环结构

时间:2018-09-27 16:47:43

标签: javascript reactjs react-native react-native-android jsx

点击api时出现错误

  createUserProfile=async()=>{
  try {
    let response = await fetch(baseUrl + 'edituserprofilesave', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        hash: this.state.hash,
        timestamp:this.state.timestamp,
        id:this.state.id,
        firstName:this.state.textFirstName,
        lastName:this.state.textLastName,
        picture: this.state.avatarSource.uri

      }),
    });
    let responseJson = await response.json();
    // alert("my response" + JSON.stringify(responseJson))
    alert("success")
  } catch (error) {
    alert(error);
  }
}

我知道错误会在哪里..它不是我从这里得到的textFirstName和textLastName。.

           <FloatingLabelInput
          label="First Name*"
          onChange={value => {
            this.setState({ textFirstName: value });
          }}
          style={[
            styles.FloatingLabelInputStyle,
            { borderBottomColor: this.state.firstNameBorder }
          ]}
        />

和类似的textLast name ..我正在更新状态值,但我不知道为什么它会引发此错误.. 比你提前

0 个答案:

没有答案