From 4f89c431fca759b5750d72c75d82fd97c1dae46a Mon Sep 17 00:00:00 2001 From: matthew1232 Date: Mon, 25 Nov 2019 12:49:00 -0800 Subject: [PATCH] Fix destructuring Fix destructuring, add body parameter to errors, convert body to JSON --- src/apis/stockx/asks/index.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/apis/stockx/asks/index.js b/src/apis/stockx/asks/index.js index b38cde1..a8d6f93 100644 --- a/src/apis/stockx/asks/index.js +++ b/src/apis/stockx/asks/index.js @@ -51,10 +51,10 @@ export default class Asks extends Base { checkStatus(res); - const { body } = res; - const { PortfolioItem: { chainId, skuUuid }} = body; - - return { chainId, skuUuid }; + const body = JSON.parse(res.body); + const { PortfolioItem } = body; + + return PortfolioItem; } async place(product, options = {}) { @@ -65,6 +65,7 @@ export default class Asks extends Base { if (!amount || !size || !product) { const error = new Error('Invalid product, amount, and/or size!'); error.status = 404; + error.body = ''; throw error; } @@ -108,10 +109,10 @@ export default class Asks extends Base { checkStatus(res); - const { body } = res; - const { PortfolioItem: { chainId, skuUuid }} = body; + const body = JSON.parse(res.body); + const { PortfolioItem } = body; - return { chainId, skuUuid }; + return PortfolioItem; } async remove(bid = {}) { @@ -146,9 +147,9 @@ export default class Asks extends Base { checkStatus(res); - const { body } = res; - const { PortfolioItem: { chainId, skuUuid } } = body; + const body = JSON.parse(res.body); + const { PortfolioItem } = body; - return { chainId, skuUuid }; + return PortfolioItem; } }