question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`request` api not exposed in babel import

See original GitHub issue

This 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:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
arempe93commented, Jun 23, 2016

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

0reactions
mzabriskiecommented, Jun 23, 2016

Works for me using axios@0.12.0. Your gist is using axios@0.5.3. I would recommend updating. http://requirebin.com/?gist=506cee6804bd4277914e64e6da1db631

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found