diff --git a/PreferHeader.http b/PreferHeader.http new file mode 100644 index 0000000..2b33e69 --- /dev/null +++ b/PreferHeader.http @@ -0,0 +1,60 @@ + +{{ + const axios = require('axios'); + + const wait = axios.get(`${baseUrl}/products`).then(res => { + let length = res.data.length; + let exists = res.data.find(item => item.id === 78); + if(length===78 && exists){ + return axios.delete(`${baseUrl}/products?id=eq.78`) + .then(res => { + return null; + }) + } + return null; + }) + exports.wait = wait; +}} +### + +POST {{baseUrl}}/products +Content-Type: application/json +Prefer: return=representation + +{ + "id": 78, + "product_name": "Saffaron", + "discontinued": 0, + "supplier_id": 12, + "category_id": 2, + "quantity_per_unit": "20 mg", + "unit_price": 100, + "units_in_stock": 50, + "units_on_order": 0, + "reorder_level": 10 +} +?? status == 201 +?? js response.parsedBody.length == 1 +?? js response.parsedBody[0].id == 78 +?? js response.parsedBody[0].product_name == Saffaron + +### + +POST {{baseUrl}}/products +Content-Type: application/json +Prefer: return=headers-only + +{ + "id": 78, + "product_name": "Saffaron", + "discontinued": 0, + "supplier_id": 12, + "category_id": 2, + "quantity_per_unit": "20 mg", + "unit_price": 100, + "units_in_stock": 50, + "units_on_order": 0, + "reorder_level": 10 +} +?? status == 201 +?? header location == /products?id=eq.78