Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs React Native Axios get method undefined不是对象_Reactjs_React Native_Axios_React Native Android - Fatal编程技术网

Reactjs React Native Axios get method undefined不是对象

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); })

当我尝试在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);
}).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';