有一个奇怪的问题。
我有一个对象
import { Component, ViewChild, ViewChildren } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
@ViewChildren('status')
public statusElements: any;
public setStatusTo(name: string): void {
this.statusElements.toArray().forEach(
(status) => {
status.nativeElement.innerHTML = name;
}
)
}
}
我也使用了npm软件包
const otherParams = {
hello: "world"
};
const params = {
payload: JSON.stringify(otherParams);
apiKey: 1234,
hmac: 13414
}
对querystring
进行了编码
params
一切正常,但问题是// post method here
url: "https://endpoint.com",
method: "POST",
query: querystring.stringify(params),
headers: {
"Content-type": "application/x-www-form-urlencoded"
}
没有发送,这是payload
无法编码querystring
的问题吗?
答案 0 :(得分:0)
尝试使用
url: "https://endpoint.com",
method: "POST",
query: querystring.stringify(params),
headers: {
"Content-type": "application/x-www-form-urlencoded","application/json"
}