Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create is not a function #319

Open
webdevhayes opened this issue Sep 14, 2023 · 3 comments
Open

create is not a function #319

webdevhayes opened this issue Sep 14, 2023 · 3 comments

Comments

@webdevhayes
Copy link

Hello,

I am not sure if this is related to this issue - #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
Copy link

aexomir commented Sep 24, 2023

same here; any updates?

@Epick362
Copy link

Epick362 commented Jan 5, 2024

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
Copy link

aexomir commented Jan 5, 2024

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 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants