Giter VIP home page Giter VIP logo

Comments (7)

adrai avatar adrai commented on May 25, 2024

regarding fetch... i don't think there is a problem with fetch, but with your cors configuration... (#30)

regarding axios... you are configuring the loadPath function, this should return a string representing the path, not directly the data
if you want to use axios you may want to configure the request option

from i18next-http-backend.

adrai avatar adrai commented on May 25, 2024

nevertheless a reproducable example would be nice

from i18next-http-backend.

otaviobonder-deel avatar otaviobonder-deel commented on May 25, 2024

Hi @adrai, thanks for replying. It's definetely not a problem with cors, I've configured it in the S3, and axios can fetch the data just fine. I tried testing with fetch on a component and the same thing happened. Axios works, fetch doesn't.

regarding axios... you are configuring the loadPath function, this should return a string representing the path, not directly the data

Can you elaborate this? I tried to return the data directly. If it's to return the path, how should I make the backend use axios instead of fetch?

Thanks!

from i18next-http-backend.

adrai avatar adrai commented on May 25, 2024

you can define your own request functionality:
image

from i18next-http-backend.

otaviobonder-deel avatar otaviobonder-deel commented on May 25, 2024

Thanks @adrai, it seems to be working now. Just to be sure the request is correctly:

request: async (options, url, payload, callback) => {
                try {
                    const translation = await axios.get(url);
                    callback({
                        status: 200,
                        data: JSON.stringify(translation.data),
                    });
                } catch (e) {
                    callback(e);
                }
            },

This should be the function, right?

from i18next-http-backend.

adrai avatar adrai commented on May 25, 2024

I don't know axios... so if it works for you then ok. 👍

from i18next-http-backend.

otaviobonder-deel avatar otaviobonder-deel commented on May 25, 2024

Thank you, closing it

from i18next-http-backend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.