我在此https://jsonapi.org/examples/#pagination中使用api时遇到问题。有谁知道如何解决这个问题?请在这里查看stackblitz链接:
getPostsPerPage(key: string, pageNumber: string) {
let headers: HttpHeaders = new HttpHeaders();
headers.append("Content-Type", "application/vnd.api+json");
headers.append("Accept", "application/vnd.api+json");
return this.httpClient.get(`${this.url}?page[number]=${pageNumber}&page[size]=10`, {
headers: headers
});
}
充分利用这些示例json API
many more at JSONPlaceholder sitw
标题也不会以这种方式附加。您需要将其分配回标题。
headers = headers.append("Content-Type", "application/json");