我正在对节点服务器进行api调用。它是一个post调用,但是响应时出现错误,但是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)
})
订阅后正确处理数据有助于您更好地查看响应数据。更好的方法是使用map()
。
this.http.post('http://localhost:3000/s/getKey', { seqKey : 'invoices' }, {
headers : header
}).map(response => response.json())
.subscribe(data => {
console.log(data)
}, error => {
console.log(error)
});