admin管理员组文章数量:1315833
I'm wondering if it's yet possible to get the value of 'X-WP-Total' in the api response.
Here is my request -
axios.get(${url}/wp-json/wp/v2/media?per_page=100&mime_type=image/jpeg).then(response => this.photo = response.data);
which successfully returns all the images from the media library and stores them in an object named photo.
I can see the header value of 'X-WP-Total' in Postman, and I am hoping to return that value without having to create a custom endpoint, or touch the theme file
I'm wondering if it's yet possible to get the value of 'X-WP-Total' in the api response.
Here is my request -
axios.get(${url}/wp-json/wp/v2/media?per_page=100&mime_type=image/jpeg).then(response => this.photo = response.data);
which successfully returns all the images from the media library and stores them in an object named photo.
I can see the header value of 'X-WP-Total' in Postman, and I am hoping to return that value without having to create a custom endpoint, or touch the theme file
Share Improve this question asked Jun 2, 2019 at 14:01 ElouiseElouise 11 silver badge1 bronze badge 1 |1 Answer
Reset to default 1Ideally, you can access those headers with response.header
, but not all headers are available publicly unless exposed manually. In your case, to access X-WP-Total
by the client, you need to set the Access-Control-Expose-Headers header on your server:
Access-Control-Expose-Headers: X-WP-Total
本文标签: javascriptReturn 39XWPTotal39 from headers in response
版权声明:本文标题:javascript - Return 'X-WP-Total' from headers in response 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741988033a2408801.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
response
object to see where Axios stores response headers – Tom J Nowell ♦ Commented Nov 17, 2020 at 12:30