node.js - 错误 - 类型错误 : Type error only on Safari after made GET request to the api server inside angular 5 app

标签 node.js angular typescript express httpclient

所以我在 Angular 5 之上制作 Web 应用程序。 问题是当我尝试从服务器调用 api 端点时。

当我收到错误响应(400+)时,似乎在 Safari 上它总是抛出并破坏应用程序。

ERROR - TypeError: Type error
ERROR CONTEXT – DebugContext_ {view: Object, nodeIndex: 0, nodeDef: Object, …}

enter image description here

但在 Chrome 上,它可以像这样正确处理错误。

GET https://api.xxxx.com/projectname/v1.0/validation/access-token 400 (Bad Request)

这是我的源代码

const baseUrl = environment.apiUrl;
const fullUrl = baseUrl + '/productname/v1.0/validation/access-token';

const headers = new HttpHeaders({
     'X-Access-Token': access_token
});

this.http.get(fullUrl, {
    headers: headers
}).subscribe((res: any) => {
   console.log(res, 'http res');
},
(error: any) => {
    console.log(error, 'http err');
});

有人知道如何解决这个问题吗?

最佳答案

经过大量调试后,我找出了导致我出现问题的问题。在每个请求中,我都会发送移动设备的名称,就我而言,它是 Shashank 的 iPhone

调用setRequestHeader header 中带有 单引号 失败,因此所有 HTTP 请求都中断了。

关于node.js - 错误 - 类型错误 : Type error only on Safari after made GET request to the api server inside angular 5 app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50325080/

相关文章:

mysql - 选择、处理和插入/更新 JSON 数据类型

javascript - 锯齿事务处理器不工作

Angular 2 : Add components at specific/nth position dynamically

TypeScript 和 ng2 rc.1 出现错误 :(20, 15) TS2304:找不到名称 'module'

typescript - bazel Rules_nodejs 无法使用自定义 package.json 位置解析模块

node.js - 使用 node.js 中的 express,客户端 cookie 未正确存储在 redis 存储中

javascript - Javascript中如何确定函数参数?

angular - 如何使用 ngx-intl-tel-input 选择默认国家/地区

javascript - 在函数调用中使用类型变量时出错

javascript - 日期选择器:无法绑定(bind)到 'bsValue',因为它不是 'input' 的已知属性