React native 在url上传递参数
我尝试使用react native访问此url,并在url中传递以下参数,而不使用json 网络和密码=mypass1234 我尝试使用下面的代码,但它不起作用,也没有连接到wifi网络React native 在url上传递参数,react-native,api,url,React Native,Api,Url,我尝试使用react native访问此url,并在url中传递以下参数,而不使用json 网络和密码=mypass1234 我尝试使用下面的代码,但它不起作用,也没有连接到wifi网络 fetch("http://192.168.4.1/credentials", { method: 'POST', headers: new Headers({ 'Content-Type
fetch("http://192.168.4.1/credentials", {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/x-www-form-urlencoded', // <-- Specifying the Content-Type
}),
body: "ssid=MY Network&password=mypass1234" // <-- Post parameters
})
.then((response) => response.text())
.then((responseText) => {
alert(responseText);
})
.catch((error) => {
console.error(error);
});
fetch(“http://192.168.4.1/credentials", {
方法:“POST”,
标题:新标题({
“内容类型”:“应用程序/x-www-form-urlencoded”,//{
警报(responseText);
})
.catch((错误)=>{
控制台错误(error);
});