#react-native #oauth-2.0 #axios #imgur
#react-native #oauth-2.0 #axios #imgur
Вопрос:
У меня есть такой простой вариант в одном из моих компонентов:
componentDidMount() {
axios
.get(
API_URL
"oauth2/authorize?client_id="
API_CLIENT_ID
"amp;response_type=token"
)
.then(function (response) {
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
}
тем не менее, я хотел бы проанализировать URL обратного вызова, который находится в приложении imgur Oauth2:
https://example.com/oauthcallback#access_token=ACCESS_TOKENamp;token_type=Beareramp;expires_in=3600
но, похоже, я не могу получить к нему доступ, я мог видеть только response.status, который равен 200, response.header и т. Д.. как получить URL-адрес?
Ответ №1:
Схема ответа на запрос axios
{
// `data` is the response that was provided by the server
data: {},
}
попробуйте это
response.data.url
Ответ №2:
Вы можете проанализировать URL-адрес ответа вашего запроса следующим образом:
response.request.responseURL