Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Api 在react native中将数据提取到数据库时出现问题。错误:";json解析错误无法识别的令牌'<'&引用;_Api_React Native_Fetch - Fatal编程技术网

Api 在react native中将数据提取到数据库时出现问题。错误:";json解析错误无法识别的令牌'<'&引用;

Api 在react native中将数据提取到数据库时出现问题。错误:";json解析错误无法识别的令牌'<'&引用;,api,react-native,fetch,Api,React Native,Fetch,在标题中,您可以尝试将内容类型更改为“application/json” 这回答了你的问题吗?JSON分析错误:无法识别的令牌' try { return fetch('http://mylinktoAPI', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Typ

在标题中,您可以尝试将内容类型更改为
“application/json”


这回答了你的问题吗?JSON分析错误:无法识别的令牌'
try {
         return fetch('http://mylinktoAPI', {
              method: 'POST',
              headers: {
                  'Accept': 'application/json',
                  'Content-Type': 'application/x-www-form-urlencoded',
              },
              body: JSON.stringify({
                  first_name: this.state.first_name,

                  last_name: this.state.last_name,

                  gender: this.state.gender,

                  blood_group: this.state.blood_group,

                  phone: this.phone,

                  email: this.email,

                  address: this.address,

              }),

          }).then((response) => response.json())
              .then((responseJson) => {
              Alert.alert(responseJson);
          }).catch((error) => {
              console.error(error);
          });
      } catch (e) {
          console.error('fetch catch error', e);
      }
};
"Content-Type", "application/json"