Naruto Uzumaki
Naruto Uzumaki

Reputation: 318

add language to header using axios

I have been creating a web application using ReactJS and Symfony, I want to add a multi language functionality to my application. The problem is when I add locale to requests as a header parameter, I'm getting a Failed to load response data, also I see the message Provisional headers are shown

const instance = axios.create({
baseURL: 'myapp.com',
headers: {
    'Content-Type': 'application/ld+json',
    locale: 'en'
}});

when I remove the parameter locale it work correctly and the request passed to the API and the worning message "Provisional headers are shown" disappear from the browser.

how can I solve the problem ?. Thanks.

Upvotes: 1

Views: 17947

Answers (2)

Naruto Uzumaki
Naruto Uzumaki

Reputation: 318

I added the locale to the list of parameters accepted in the allow_header section of the API and now it works.

allow_headers: ['Content-Type', 'Authorization', 'locale']

Upvotes: 0

Someone Special
Someone Special

Reputation: 13588

Do you mean you want to set the accept language?

headers: {
      "Accept-Language": "en-US,en;"
}

Upvotes: 4

Related Questions