Hello is it possible to run ES6 module function which is using axios to call API as package.json script using node v12 ?
I was trying to use package like run-func
and turning file into .mjs
but it didn't work.
I would like to have something like that:
"scripts": {
"mocks:enable": "run-func mocks.js enableMocks"
}
Function while create api and myApi lives in another file
// instance.js
import axios from "axios";
createApiInstance = (baseUrl) => {
const api = axios.create({
baseURL: baseUrl,
});
return api;
};
export const myApi = createApiInstance(url)
//mocks.js
export function enableMocks() {
return myApi.post("mocks", STATUS.enabled);
}