angular - 得到错误 OK 作为来自 http 帖子的响应
问题描述
我正在对节点服务器进行 api 调用。它是一个post call,但我收到错误作为响应,但firebase上的数据发生了变化。
const header : HttpHeaders = new HttpHeaders()
header.append('Content-Type', 'application/x-www-form-urlencoded')
this.http.post('http://localhost:3000/s/getKey', { seqKey : 'invoices' }, {
headers : header
}).subscribe(data => {
console.log(data)
})
更新
解决方案
我有同样的问题。我在后端使用 Spring REST API,它只是返回一个字符串,这是一个问题,因为 Angular HttpClient 需要 JSON。我通过将我的 String 包装在一个简单的 POJO 中并返回它来解决它。
推荐阅读
- odoo - 在 Odoo 中禁用或隐藏保存按钮
- php - 为什么全局变量在 Laravel 控制器中被重置
- c# - 是否有适用于 Visual Studio Mac 的 C# Bot Builder V4 SDK 模板?
- r - 具有多个条件的单词出现的总和
- python - 在 tensorflow.js 中,重塑张量的推荐方法是什么?
- typescript - TypeError:无法读取 null 的属性“isSkipSelf”(Angular7)
- html - 对 th 的后代不应用换行
- autotools - Autotools:$VAR、$(VAR) 和 ${VAR} 和 ${CC-cc} 与 ${CC} 的区别
- botframework - 在 azure 上发布的聊天机器人 Hands-Off - 提供连接错误模拟器:无法发布活动。未经授权
- eslint - 是否存在 eslint 规则来防止类被重新分配?