Ninja Turtle
Ninja Turtle

Reputation: 1353

Angular http client not working with translation on in IOS chrome browser?

I have angular project built in angular 10. I am getting issue in calling api from IOS chrome browser when i turn on google translation from browser.

If i do not turn on translation it is giving me correct response for API

However when i turn on translation i am getting this error.

InvalidAccessError The object does not support the operation or argument

Error is happening only when i do translation from browser if i do translation from settings in Iphone the it is working fine.

and it is also working fine in all browsers in laptop.

If use javascript fetch function instead of angular HttpClient then it is working fine with HttpClient request is not even going to server. It is giving error even before sending request.

Upvotes: 3

Views: 1267

Answers (1)

Aakash Garg
Aakash Garg

Reputation: 10979

Its because HTTPClient expects a json in response by default and when you turn on translation, its no more a json. Try receiving response like

this.http.post(this.url, body, {responseType: 'text'}).subscribe((res)=> console.log(res));

also body should be a json like

body=JSON.stringify(data);

if it prints then if you feel its not a json then map it to javascript object via your code, if it seems a json then use

JSON.parse(res);

Upvotes: 4

Related Questions