Reputation: 637
The following statement is giving me a err: TypeError: axios.request is not a function
when I run the api.
const content = await axios.request(getData(id)).then(res => res.data)
Where getData returns a configuration object.
I am importing axios like so:
import * as axios from 'axios'
Upvotes: 1
Views: 19833
Reputation: 101
@deerawan's Answer looks correct.
but still you are confused you can refer axios reference page.
https://kapeli.com/cheat_sheets/Axios.docset/Contents/Resources/Documents/index
Upvotes: 0
Reputation: 8443
When we look at axios type definition file, we can see that it uses default export
. So, instead of using import * as axios from axios
, the correct way is using import for default.
import axios from 'axios'
axios.request({ // params });
Tested in vscode, it didn't give compile error.
Hope it helps.
Upvotes: 2