infinitered / apisauce

Axios + standardized errors + request/response transforms.
MIT License
2.78k stars 184 forks source link

create is not a function #319

Open webdevhayes opened 1 year ago

webdevhayes commented 1 year ago

Hello,

I am not sure if this is related to this issue - https://github.com/infinitered/apisauce/issues/316

I have tried v3.0.1 and I still get this error when trying to create the apisauce instance.

TypeError: Bo.create is not a function

I am sure if this is a issue related to vite/esbuild though as if I run this through vite dev everything works as expected. Doing a production build using vite then creates the issue.

I have had to revert back to v2.1.6 and everything is working again.

Just for clarity this is my file.

import {create} from 'apisauce';

const APP_ENV = import.meta.env.VITE_APP_ENV;
const API_PROD_URL = 'url';
const API_LOCAL_URL = 'url';

const httpClient = create({
    baseURL: APP_ENV === 'local' ? API_LOCAL_URL : API_PROD_URL,
});

export default httpClient;

I hope this helps? If you want any help to try and replicate this then let me know :). I hope I have given a give enough explanation.

aexomir commented 11 months ago

same here; any updates?

Epick362 commented 8 months ago

Experiencing the same issue. Probably related to how axios is being imported and used in apisauce as ESbuild and Vite are using ESM and possibly not importing the ESM version of axios.

aexomir commented 8 months ago

Update: My mistake was that I was importing api from: Import httpClient from '.' But I had to import it from: Import httpClient from './index.ts' I haven't still found out the reason behind but this might help you find the problem 🤔