在角中使用Json Api

问题描述 投票:0回答:1

我在此https://jsonapi.org/examples/#pagination中使用api时遇到问题。有谁知道如何解决这个问题?请在这里查看stackblitz链接:

CLICK HERE

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
    });
  }
angular angular7 angular-services angular-httpclient json-api
1个回答
0
投票

充分利用这些示例json API

Users Json

Posts Json

many more at JSONPlaceholder sitw

标题也不会以这种方式附加。您需要将其分配回标题。

headers = headers.append("Content-Type", "application/json");
© www.soinside.com 2019 - 2024. All rights reserved.