ruby on rails - How to you get the response headers with shopify_api gem?
I'm trying to implement pagination with the the Rails shopify_api gem (latest version 11.1.0). According to their docs (https://shopify.dev/api/usage/pagination-rest) the next page link is in the response headers.
How do you get the response headers?
orders = ShopifyAPI::Order.all(limit: 250) response_header = ?
You used to be able to use orders.fetch_next_page to get the next page but that's not an available method any more (I believe since shopify_api version 10.0.0), and now you have to check the headers.
There is some documentation which I found recently - https://github.com/Shopify/shopify-api-ruby/blob/main/docs/usage/rest.md#pagination (https://github.com/Shopify/shopify-api-ruby/blob/main/docs/usage/rest.md#pagination)
products = ShopifyAPI::Product.all(session: session, limit: 10) loop do some_function(products) break unless ShopifyAPI::Product.next_page? products = ShopifyAPI::Product.all( session: session, limit: 10, page_info: ShopifyAPI::Product.next_page_info ) end
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.