We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents a2c7be0 + 1eba1c9 commit 88eff82Copy full SHA for 88eff82
pages/api/get-products.js
@@ -7,17 +7,29 @@ const api = new WooCommerceRestApi({
7
version: "wc/v3"
8
});
9
10
+/**
11
+ * Get Products.
12
+ *
13
+ * Endpoint /api/get-products or '/api/get-products?perPage=2'
14
15
+ * @param req
16
+ * @param res
17
+ * @return {Promise<void>}
18
+ */
19
export default async function handler(req, res) {
20
+
21
const responseData = {
22
success: false,
23
products: []
24
}
25
26
+ const { perPage } = req?.query ?? {};
27
28
try {
29
const { data } = await api.get(
30
'products',
31
{
- per_page: 50
32
+ per_page: perPage || 50
33
34
);
35
0 commit comments