所以,我只是在学习 axios,一切看起来都正确,但我想我不了解有关全局作用域的东西。这是我的代码:
axios.get('https://api.github.com/users/social-collab')
.then(function (response) {
console.log('Response: ', response.data);
const data = response.data;
return data;
})
.catch(function (handleError) {
console.log('Error: ', handleError);
},[]);
const myData = function(data) {
name = data.name; // This is the line with the error: data is not defined. But it is, isn't it?
return name;
}
console.log(myData(data));
Run Code Online (Sandbox Code Playgroud)