`request` api not exposed in babel import
See original GitHub issueThis code will raise Uncaught TypeError: axios.request is not a function
:
import * as axios from 'axios'
axios.request({
method: 'GET',
url: '/categories/1'
})
Outputting the axios
object to console results in:
Object {defaults: Object, interceptors: Object}
all: function all(promises)
create: function create(defaultConfig)
default: function wrap()
defaults: Object
delete: function wrap()
get: function wrap()
head: function wrap()
interceptors: Object
patch: function wrap()
post: function wrap()
put : function wrap()
spread: function spread(callback)
__proto__: Object
Using either axios({ ... })
or axios.request({ ... })
will not work for es6 imports
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Upgrade to Babel 7 (API)
If you import a Babel package in a library you may need to use .default when ... The API will expose an assertVersion...
Read more >Unable to expose a component library in react with webpack ...
For this, Babel produces the following code exports.ImageEditor = ImageEditor;. Look, no extra default key, and everything work as expected.
Read more >import cjs strange behaviour (interop with babel) #480 - GitHub
The solution to this is in the package that's transpiled: their entry points should not be transpiled, they should module.exports = require('./ ...
Read more >babel-loader - webpack
The following approach will not work either: require('@babel/runtime/core-js/promise').default ...
Read more >babel-plugin-module-resolver - npm
Description. This plugin can simplify the require/import paths in your project. For example, instead of using complex relative paths like ../.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok - I upgraded from 0.9 to 0.12 in my app and it seemed to fix it for me, along with using
import axios from 'axios'
.Thanks for the replies
Works for me using
axios@0.12.0
. Your gist is usingaxios@0.5.3
. I would recommend updating. http://requirebin.com/?gist=506cee6804bd4277914e64e6da1db631