1

I'm getting this error when I try to use get method in Axios:

undefined is not an object (evaluating '_axios.axios.get')

How to solve this issue?

2 Answers 2

6

You are probably importing wrong by trying to import axios as an object.

Wrong:

import { axios } from 'axios';

Right:

import axios from 'axios';
Sign up to request clarification or add additional context in comments.

Comments

0

You should provide more of your code. And this code works for me:

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

check your package.json also, and run npm install if you haven't.

...
  "dependencies": {
    "axios": "^0.18.0",
...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.