mkody / twitch-emoticons

Gets Twitch, BTTV, FFZ and 7TV emotes as well as parsing text to emotes!
https://mkody.github.io/twitch-emoticons/
MIT License
39 stars 12 forks source link

Axios error in EmoteFetcher (Uncaught TypeError: axios.get is not a function) #48

Closed CJDAutorio closed 5 months ago

CJDAutorio commented 5 months ago

Hey mkody, I'm getting the following error when trying to initialize the emote fetcher:

Uncaught TypeError: axios.get is not a function
    at EmoteFetcher._getRawBTTVEmotes (EmoteFetcher.js:126:1)
    at EmoteFetcher.fetchBTTVEmotes (EmoteFetcher.js:256:1)
    at ApiUtils.createEmoteFetcher (ApiUtils.js:67:1)
    at Main (Main.jsx:19:1)
    at renderWithHooks (react-dom.development.js:15486:1)
    at mountIndeterminateComponent (react-dom.development.js:20103:1)
    at beginWork (react-dom.development.js:21626:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1)
    at invokeGuardedCallback (react-dom.development.js:4277:1)

This is how I'm trying to initialize the fetcher in my project:

ApiUtils.js

    static createEmoteFetcher(apiClient, channelId) {
        const fetcher = new EmoteFetcher(null, null, {
            apiClient: apiClient
        });

        Promise.all([
            // Twitch global
            fetcher.fetchTwitchEmotes(),
            // Twitch channel
            fetcher.fetchTwitchEmotes(channelId),
            // BTTV global
            fetcher.fetchBTTVEmotes(),
            // BTTV channel
            fetcher.fetchBTTVEmotes(channelId),
            // 7TV global
            fetcher.fetchSevenTVEmotes(),
            // 7TV channel
            fetcher.fetchSevenTVEmotes(channelId),
            // FFZ global
            fetcher.fetchFFZEmotes(),
            // FFZ channel
            fetcher.fetchFFZEmotes(channelId)
        ]).then(() => {
            return fetcher;
        }).catch((err) => {
            console.error(err);
        })
    }

Main.jsx

    // Returns an instance of the AppTokenAuthProvider class from @twurple/auth.
    const authProvider = ApiUtils.getAuthProvider(CLIENT_ID, CLIENT_SECRET);

    // Returns a new instance of the ApiClient class with the @twurple/auth authProvider.
    const apiClient = ApiUtils.getApiClient(authProvider);

    // Creates an instance of EmoteFetcher and fetches emotes using the example fetch options/sources.
    const fetcher = ApiUtils.createEmoteFetcher(apiClient, CHANNEL_ID);

Thanks again, and let me know if you need anything else from my side!

CJDAutorio commented 5 months ago

Wait I'm just stupid and returned the fetcher in the then() block 😭