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

shahr's avatar
Level 10

How to installer axios in laravel project

I'm a newbie. I have been coding my website for 2 weeks, and now the job is going to be finished, But I don't know how to install axios in my project. Please help me to install axios in laravel.

0 likes
2 replies
LaryAI's avatar
Level 58

To install axios in your Laravel project, you can use npm. Here are the steps:

  1. Open your terminal and navigate to your Laravel project directory.
  2. Run the following command to install axios:
npm install axios
  1. Once the installation is complete, you can start using axios in your project. Here's an example of how to make a GET request using axios:
axios.get('/api/users')
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });

In this example, we're making a GET request to the /api/users endpoint and logging the response data to the console. You can replace this with your own endpoint and logic.

That's it! You should now be able to use axios in your Laravel project.

1 like
SDCODE's avatar
npm install axios

in vue file

import axios from "axios";

Please or to participate in this conversation.