如何解决从axios获取网址在React Native中获取响应
我在其中一个组件中有一个简单的示例:
componentDidMount() {
axios
.get(
API_URL +
"oauth2/authorize?client_id=" +
API_CLIENT_ID +
"&response_type=token"
)
.then(function (response) {
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
}
但是,我想解析来自imgur Oauth2应用程序的回调URL:
https://example.com/oauthcallback#access_token=ACCESS_TOKEN&token_type=Bearer&expires_in=3600
但是似乎无法访问它,我只能看到response.status是200,response.header等。如何获取url?
解决方法
axios请求的响应模式
{
// `data` is the response that was provided by the server
data: {},}
尝试
response.data.url
,
您可以这样解析请求的响应网址:
response.request.responseURL
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。