Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/apis/stockx/bids/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export default class Bids extends Base {
if (!amount || !skuUuid || !chainId) {
const error = new Error('Invalid amount product id, and/or ask id!');
error.status = 404;
error.body = '';
throw error;
}

if (!bearer) {
const error = new Error('Please login first!');
error.status = 401;
error.body = '';
throw error;
}

Expand Down Expand Up @@ -49,10 +51,10 @@ export default class Bids extends Base {

checkStatus(res);

const { body } = res;
const { PortfolioItem: { chainId, skuUuid } } = body;
return { chainId, skuUuid };
const body = JSON.parse(res.body);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the other PR. I'm not sure the JSON.parse() is needed. Please correct me if I'm wrong!

const { PortfolioItem } = body;

return PortfolioItem;
}

async place(product, options = {}) {
Expand All @@ -63,12 +65,14 @@ export default class Bids extends Base {
if (!amount || !size || !product) {
const error = new Error('Invalid product, amount, and/or size!');
error.status = 404;
error.body = '';
throw error;
}

if (!bearer) {
const error = new Error('Please login first!');
error.status = 401;
error.body = '';
throw error;
}

Expand All @@ -77,6 +81,7 @@ export default class Bids extends Base {
if (!desiredSize || (desiredSize && !desiredSize.uuid)) {
const error = new Error('Size not found!');
error.status = 404;
error.body = '';
throw error;
}

Expand Down Expand Up @@ -105,10 +110,10 @@ export default class Bids extends Base {

checkStatus(res);

const { body } = res;
const { PortfolioItem: { chainId, skuUuid } } = body;
const body = JSON.parse(res.body);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too

const { PortfolioItem } = body;

return { chainId, skuUuid };
return PortfolioItem;
}

// TODO!
Expand Down Expand Up @@ -143,9 +148,9 @@ export default class Bids extends Base {

checkStatus(res);

const { body } = res;
const { PortfolioItem: { chainId, skuUuid } } = body;
const body = JSON.parse(res.body);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

const { PortfolioItem } = body;

return { chainId, skuUuid };
return PortfolioItem;
}
}