admin管理员组文章数量:1415664
I am trying to create a function to grab my profile data from LinkedIn. For debugging though I need to see what data is being mapped over or before that. But not sure where to put my console log to see the data its receiving. Any help is much appreciated :)
// Grabs profile data from the json url
private getProfiles() {
let config = {
headers: {'Authorization':'Bearer AQVVEqG......'}
}
axios
.get("/" + "", config)
.then(response =>
response.data.map(profile => ({
name: `${ profile.localizedLastName }`,
}))
)
.then(profiles => {
this.setState({
profiles,
isLoading: false
});
})
// We can still use the `.catch()` method since axios is promise-based
.catch(error => this.setState({ error, isLoading: false }));
}
I am trying to create a function to grab my profile data from LinkedIn. For debugging though I need to see what data is being mapped over or before that. But not sure where to put my console log to see the data its receiving. Any help is much appreciated :)
// Grabs profile data from the json url
private getProfiles() {
let config = {
headers: {'Authorization':'Bearer AQVVEqG......'}
}
axios
.get("https://cors-anywhere.herokuapp./" + "https://api.linkedin./v2/me", config)
.then(response =>
response.data.map(profile => ({
name: `${ profile.localizedLastName }`,
}))
)
.then(profiles => {
this.setState({
profiles,
isLoading: false
});
})
// We can still use the `.catch()` method since axios is promise-based
.catch(error => this.setState({ error, isLoading: false }));
}
Share Improve this question asked Oct 4, 2019 at 13:08 BennKingyBennKingy 1,5933 gold badges27 silver badges54 bronze badges 1- you are not returning anything from the first Promise.then – Dan Starns Commented Oct 4, 2019 at 13:12
2 Answers
Reset to default 2Just put it in the callback function.
.then(response => {
console.log(response);
response.data.map(profile => ({
name: `${ profile.localizedLastName }`,
}))
})
.then(profiles => {
console.log(profiles);
this.setState({
profiles,
isLoading: false
});
})
You can do
.then(response => {
console.log(response);
response.data.map(profile => ({
name: `${ profile.localizedLastName }`,
}))
})
本文标签: javascriptWhere to put console log in axios get requestStack Overflow
版权声明:本文标题:javascript - Where to put console log in axios get request? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745220604a2648377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论