问题
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.
回答1:
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);
来源:https://stackoverflow.com/questions/65247153/angular-http-client-not-working-with-translation-on-in-ios-chrome-browser