0

I am new to Axios and I am dealing with my first issue! I installed it with

npm install axios

and I get this error! enter image description here

Also, I get an ENOENT error: no such file or directory, open /path/../../../ Can someone explain the reason?

Thank you!

UPDATED:

I no longer get the ENOENT error.

THE FIX:

Was to change the name directory to something else rather than axios to axiosapi or anything else!

NEW ISSUE :

const axios = require('axios');

const api_url = 'https://opentdb.com/api.php?amount=1';
console.log(api_url);


axios.get(api_url)
.then(
    response => {
        if(!response.ok) {
        throw Error(response);
        }
        return response;
    }
)
.then( response => console.log(response) )

.catch( err =>  console.log(err) )

Uncaught ReferenceError: require is not defined at axioss.js:1

Evan
  • 583
  • 1
  • 5
  • 11

1 Answers1

0

If you are installing globally use npm install -g axios.

Otherwise you need to create a project in your current directory: npm init -y

Adil Khan
  • 63
  • 3
  • Thank you very much! And what is the use of -y flag? – Evan Oct 22 '18 at 20:06
  • I found it! Its just uses the default parameters of npm without the inquire at the beginning – Evan Oct 22 '18 at 20:08
  • hi @user789703 it does not work still! The same issue but the npm init -y worked just fine! All the node modules along with axios were succesfully installed! – Evan Oct 22 '18 at 20:43