如何在React原生android中使用https api



在reactnavtive应用程序中,我们在axios中使用"http"作为url,一切都很好,现在我们将"http"更改为"https",但Apis失败了。。。和应用程序不工作。。。为什么?请帮帮我。

此调用适用于HTTP和HTTPS对于POST CALL,请尝试此示例

fetch('http://mywebsite.com/endpoint/', {
method: "POST",
headers: {
// Authorization: "Bearer " + Token,
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
// sending data userID username, password, etc
}),
})
.then((response) => response.json())
.then((responseJson) => {
// Response will here
})
.catch((error) => {
alert(error);
});

对于GET CALL,请尝试此示例

fetch('http://mywebsite.com/endpoint/', {
method: "GET",
headers: {
// Authorization: "Bearer " + Token,
// OR USER name PASSworrd
Accept: 'application/json',
'Content-Type': 'application/json'
},
})
.then((response) => response.json())
.then((responseJson) => {
// Response will here
})
.catch((error) => {
alert(error);
});

我找到了这个问题的答案,我的url是:'https://185.305.1.13/index.image.png',我们为图像添加了domin,url被更改:'https://image.com/index.image.png'。。。和revso

相关内容

最新更新