Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

amk's avatar
Level 4

axios is not defined...?

app.js:722 
[Vue warn]: Error in mounted hook: "ReferenceError: axios is not defined"
0 likes
2 replies
ReznoR's avatar

I came at the same issue. My steps:

npm install axios

Then putting

const axios = require('axios');

Just before calling axios.post() etc.

I also discovered that I accidentally commented out require('./bootstrap'); line in the resources\js\app.js file. Because I thought that it was Twitter's Bootstrap (and not Laravel's bootstrap - if you know what I mean). This prevented Laravel from using

window.axios = require('axios');

from the resources\js\bootstrap.js file. And that's why I needed const axios = require('axios'); in my method. With window.axios = require('axios'); it doesn't seem to be needed.

Ahh, I just have so much to learn.

4 likes

Please or to participate in this conversation.