Named and default export in a single file

I am trying to put by default and by export name in a single file. Example:

// file name : utils/fetch export default fetchUtil; module.exports = { fetch : fetchUtil, post, put, get, }; // import code import fetch from 'utils/fetch'; 

My code works fine with the web package, however errors appear in the browser:

fetchInit.js: 27 Uncaught TypeError: (0, _fetch2.default) is not a function

Am I missing something or is this not a way to do the default & named import in the same file?

+14
source share
1 answer

Found a solution here: http://exploringjs.com/es6/ch_modules.html

I basically had to do

 export default fetchUtil export {fetchUtil as fetch, post, put, get} 
+27
source

Source: https://habr.com/ru/post/1258335/


All Articles