i18next / i18next-http-backend

i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
MIT License
454 stars 71 forks source link

options not merged ? #36

Closed franck34 closed 3 years ago

franck34 commented 3 years ago

Hi,

In a browser context, seem's that options are not taken.

        var boptions = {
            queryStringParams: { v: '1.2.3' },
        };

        var backend = new i18nextHttpBackend(boptions);

You can see in the network console that the query string is never passed.

After some investigation i found that.

Actual (not working, chrome browser):

      var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

Expected (working)

      var options = arguments.length > 1 && arguments[0] !== undefined ? arguments[0] : {};

Cheers

adrai commented 3 years ago

There's a test here: https://github.com/i18next/i18next-http-backend/blob/master/test/request.spec.js#L21 and this is the relevant code: https://github.com/i18next/i18next-http-backend/blob/master/lib/request.js#L32 I can't reproduce your issue. Can you provide a codesandbox exampe?

franck34 commented 3 years ago

https://codesandbox.io/s/bold-ives-2rcyo?file=/src/index.js

You are supposed to see test.json?v=xxxxxxx in network console, but not.

franck34 commented 3 years ago

I see your sample in React, which is working. Perhaps something related to pure js usage ?

adrai commented 3 years ago

You are passing the options in the wrong way. Either: https://codesandbox.io/s/spring-violet-k5yfj The options are passed as second argument when using the constructor function.

Or: https://codesandbox.io/s/romantic-microservice-m4vm5

franck34 commented 3 years ago

Tssss ... i feel stupid a second time lol

Thanks a lot.

Closing !

adrai commented 3 years ago

Don't worry happens to me too ;-)

If you like this module don’t forget to star this repo. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project.

There are many ways to help this project 🙏