https api 在 React-native-android 中如何工作?
How work https api in React-native-android?
在 react native 应用程序中,我们使用 'http' for url in axios 并且一切正常,现在我们将 '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',我们为图像添加域,并且 url 收费:'https://image.com/index.image.png'... 和 revso
在 react native 应用程序中,我们使用 'http' for url in axios 并且一切正常,现在我们将 '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',我们为图像添加域,并且 url 收费:'https://image.com/index.image.png'... 和 revso