Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is module export create a new instance each time when import [duplicate]

// src/utils/http.js
import axios from 'axios';

const axiosInstance = axios.create({
  baseURL: process.env.VUE_APP_API_BASE_URL,
});

export default axiosInstance;''

when import the above module import http from './http' does it create a new axios instance each time? or it is singleton?

like image 580
pythoniku Avatar asked Apr 28 '18 05:04

pythoniku


1 Answers

"ES6 Modules are singletons - the instance is created when module is loaded."

like image 93
Sergey Avatar answered Sep 28 '22 02:09

Sergey