Skip to content

axios commonjs correct way to import to gain typings? [vscode intellisense] #2226

@the-vampiire

Description

@the-vampiire

Describe the issue
what is the correct way to import axios in node using CommonJS in order to use the typings? i am not using typescript unlike this issue

Example Code

const axios = require('axios'); // no typings but everything still works

const axios = require('axios').default; // has typings and everything works

Expected behavior, if applicable
i expected to have typings for vscode intellisense when importing axios using CommonJS require() syntax described in the documentation.

i did not see any information about having to append .default to the import. maybe worth including this in the docs? for the record the import still works (axios.get() etc) but there is no typing intellisense.

Environment:

  • Axios Version: 0.19.0
  • OS: OSX 10.14.5
  • node: 10.15.3
  • vscode: 1.34.0

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

basic import
Screen Shot 2019-06-13 at 12 29 23 AM

import with .default
Screen Shot 2019-06-13 at 12 29 34 AM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions