如何在Shopify Rest JS中获取所有产品和分页
我想将所有产品从Shopify的一家商店放到我的数据库中。但是我只能得到250种产品。我不明白如何使用分页/page_info,如其文档中所述。
https://xxx.myshopify.com/admin/products/count.json
{
"count": 492
}
const client = new Shopify.Clients.Rest(store.shop_name + ".myshopify.com", store.access_token);
let data = await client.get({
path: 'admin/products/count.json',
query: {limit: 250}
})
如果我使用page_info = abcdefg,然后尝试下一页page_info = hijklmn,则都获得相同的值。请帮助我理解。
I want to put all the products from one store in shopify to my database. But i can only get 250 products. I don't understand how to use pagination/page_info as explained in their documentation.
https://xxx.myshopify.com/admin/products/count.json
{
"count": 492
}
const client = new Shopify.Clients.Rest(store.shop_name + ".myshopify.com", store.access_token);
let data = await client.get({
path: 'admin/products/count.json',
query: {limit: 250}
})
if i use page_info = abcdefg and then try for next page page_info = hijklmn, it both get the same value. pls help me to understand..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以来进行分页
https://shopify.dev/api/api/admin-rest/不稳定/资源/产品#get-products
示例:
首先请求响应250产品=>获取产品的最后一个ID返回的
secord请求:您必须添加params 以来(上述ID)
简而
https://xxx.myshopify.com/admin/admin/products/products/count.json
You can using since_id to pagination
https://shopify.dev/api/admin-rest/unstable/resources/product#get-products
Example:
first request response 250 products => get the last id of the product returned
secord request: you must add params since_id (id of above)
In short: you can fetch all product same with count when call api
https://xxx.myshopify.com/admin/products/count.json