简体   繁体   中英

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM