0

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

1
  • If you can see those headers in postman then Axios will be getting them too, you just need to inspect the response object to see where Axios stores response headers
    – Tom J Nowell
    Nov 17 '20 at 12:30
1

Ideally, 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.