首页 > 解决方案 > 标题的值不能从 ReadablenativeMap 转换为字符串

问题描述

InsertDataToServer = () => {
const { pinValue1 } = this.state;
const { pinValue2 } = this.state;
const { pinValue3 } = this.state;
const { pinValue4 } = this.state;
var String_3 = pinValue1.concat(" " , pinValue2);
var String_4 = String_3.concat(" " ,  pinValue3);
var String_5 = String_4.concat(" " ,  pinValue4);

fetch("http://www.aonde.biz/mobile/doLogin.php", {
  method: "POST",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "pin":212,

  })
})
  .then(response => response.json())
  .then(responseJson => {
    // Showing response message coming from server after inserting records.
    Alert.alert(responseJson);
  })
  .catch(error => {
    console.error(error);
  });

在上面的代码中,当我传递 pin 参数 API 时显示此错误。谢谢,在图像中显示完整的错误请给一些想法如何解决这个问题。

标签: androidiosreactjsreact-nativeexpo

解决方案


当代码从以下位置更改时,此错误已修复:

Alert.alert('Error:', error)

至:

Alert.alert('Error:', error.message)


推荐阅读