Here is how I'm using axios in my nodejs project, (n.b. @ts-ignore is a temporary measure while I figure this out):
/**
* Gets the current latest version of MTG JSON
* @returns {Promise<string>} latest json version
*/
async function getMtgJsonVersion() {
try {
// @ts-ignore
const { data } = await axios(metaUrl);
return data.date;
} catch (error) {
console.error('Could not fetch MTG JSON metadata');
throw error;
}
}
// ... elsewhere in my code ....
// @ts-ignore
const { data, headers } = await axios({
url,
method: 'GET',
responseType: 'stream',
});
And it's based on this tutorial by Future Studios
The axios documentations says about using the Axios API this was:
// Send a GET request (default method)
axios('/user/12345');
// GET request for remote image in node.js
axios({
method: 'get',
url: // shortened link removed,
responseType: 'stream'
})
.then(function (response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});
I don't 'speak' typescript, but these are the type definitions I see in my node_modules:
export interface AxiosInstance {
(config: AxiosRequestConfig): AxiosPromise;
(url: string, config?: AxiosRequestConfig): AxiosPromise;
...
}
export interface AxiosStatic extends AxiosInstance { ... }
some code cut for brevity
Which looks like it should be happy with how I'm calling it?
But I am getting this error:
This expression is not callable.
Type 'typeof import("/home/castone/ponder/node_modules/axios/index")' has no call signatures.ts(2349)
I have axios version as '^0.19.2' in my package.json file. I'm happy to upgrade (the latest version at time of writing seems to be '0.24.0', but I'd prefer to address this issue separately first if possible. I'm also on WSL1 if that matters?