Gregg
Gregg

Reputation: 35864

Axios and Webpack

I'm really new to Webpack and I'm using axios with a React project. I installed axios via npm and then I'm importing it like so when I want to use it:

import axios from 'axios/dist/axios.min.js';

Webpack takes care of the rest. Is this the "right" way to do it?

Upvotes: 5

Views: 16653

Answers (1)

Nick Uraltsev
Nick Uraltsev

Reputation: 25907

I think the standard way of doing this is as follows:

import axios from 'axios';

The UMD build (axios.min.js) can be helpful when you need to include axios in a <script> tag:

<script src="https://npmcdn.com/axios/dist/axios.min.js"></script>

Upvotes: 16

Related Questions