diff options
Diffstat (limited to 'iridescence/src/api')
-rw-r--r-- | iridescence/src/api/dichroism.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/iridescence/src/api/dichroism.js b/iridescence/src/api/dichroism.js index 610941c..c2cc93c 100644 --- a/iridescence/src/api/dichroism.js +++ b/iridescence/src/api/dichroism.js @@ -18,7 +18,7 @@ export default class Dichroism { const photos = await this._sendRequest("photos", options); return photos.map(p => new PhotoSet(p)); } catch (err) { - console.error(err.message); + console.error("Dichroism: " + err.message); return null; } } @@ -28,7 +28,7 @@ export default class Dichroism { const products = await this._sendRequest("products", null); return products.map(p => new Product(p)); } catch (err) { - console.error(err.message); + console.error("Dichroism: " + err.message); return []; } } @@ -36,14 +36,17 @@ export default class Dichroism { async updateProduct(fieldDiff) { const options = { method: "PATCH", - body: fieldDiff + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(fieldDiff) }; try { const product = await this._sendRequest("products", options); return new Product(product); } catch (err) { - console.error(err.message); + console.error("Dichroism: " + err.message); return null; } } @@ -51,14 +54,17 @@ export default class Dichroism { async createProduct(newProduct) { const options = { method: "POST", - body: newProduct + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(newProduct) }; try { const product = await this._sendRequest("products", options); return new Product(product); } catch (err) { - console.error(err.message); + console.error("Dichroism: " + err.message); return null; } } |