Reactjs React Native Axios get method undefined不是对象
当我尝试在Axios中使用get方法时,出现以下错误: undefined不是对象(计算'\u axios.axios.get')Reactjs React Native Axios get method undefined不是对象,reactjs,react-native,axios,react-native-android,Reactjs,React Native,Axios,React Native Android,当我尝试在Axios中使用get方法时,出现以下错误: undefined不是对象(计算'\u axios.axios.get') 如何解决这个问题?您应该提供更多的代码。这个代码对我来说很有用: import axios from 'axios'; axios.defaults.baseURL = [Input Your Base URL Here]; axios.get('/').then(function (response) { console.log(response); })
如何解决这个问题?您应该提供更多的代码。这个代码对我来说很有用:
import axios from 'axios';
axios.defaults.baseURL = [Input Your Base URL Here];
axios.get('/').then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
同时检查您的包.json
,如果没有,请运行npm install
...
"dependencies": {
"axios": "^0.18.0",
...
您应该提供更多的代码。这个代码对我来说很有用:
import axios from 'axios';
axios.defaults.baseURL = [Input Your Base URL Here];
axios.get('/').then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error);
});
同时检查您的包.json
,如果没有,请运行npm install
...
"dependencies": {
"axios": "^0.18.0",
...
尝试将
axios
作为对象导入时,可能导入错误
错:
import { axios } from 'axios';
对:
import axios from 'axios';
尝试将
axios
作为对象导入时,可能导入错误
错:
import { axios } from 'axios';
对:
import axios from 'axios';