From 05430c3386c91b31031d9340f35f437e7f82b4c2 Mon Sep 17 00:00:00 2001 From: Zack Hatlen Date: Tue, 6 Sep 2022 14:15:20 +0300 Subject: [PATCH] master --- index.js | 19 +++++++++---------- package.json | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index 4f624b3..216ec45 100644 --- a/index.js +++ b/index.js @@ -101,15 +101,15 @@ export default ({woocommerceUrl, consumerKey, consumerSecret, body: JSON.stringify(params.data), }).then(({ json }) => ({ data: json })), - updateMany: (resource, params) => { - const query = { - include: Array(params.ids), - }; - return httpClient(`${woocommerceUrl}/wp-json/wc/v3/${resource}?${stringify(query)}`, { - method: 'PUT', - body: JSON.stringify(params.data), - }).then(({ json }) => ({ data: json })); - }, + updateMany: (resource, params) => + Promise.all( + params.ids.map(id => + httpClient(`${woocommerceUrl}/wp-json/wc/v3/${resource}/${id}`, { + method: 'PUT', + body: JSON.stringify(params.data), + }) + ) + ).then(responses => ({ data: responses.map(({ json }) => json.id) })), delete: (resource, params) => httpClient(`${woocommerceUrl}/wp-json/wc/v3/${resource}/${params.id}`, { @@ -121,7 +121,6 @@ export default ({woocommerceUrl, consumerKey, consumerSecret, params.ids.map(id => httpClient(`${woocommerceUrl}/wp-json/wc/v3/${resource}/${id}`, { method: 'DELETE', - body: JSON.stringify(params.data), }) ) ).then(responses => ({ data: responses.map(({ json }) => json.id) })), diff --git a/package.json b/package.json index 47ed344..9d7e020 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ra-data-woocommerce", - "version": "1.1.3", + "version": "1.1.4", "description": "WooCommerce REST API data provider for react-admin", "main": "index.js", "scripts": {