@faststore/api 2.1.98 → 2.1.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.esm.js CHANGED
@@ -91,7 +91,7 @@ var packageJson = {
91
91
  };
92
92
 
93
93
  const USER_AGENT = `${packageJson.name}@${packageJson.version}`;
94
- const fetchAPI = async (info, init, getHeaders) => {
94
+ const fetchAPI = async (info, init) => {
95
95
  const response = await fetch(info, {
96
96
  ...init,
97
97
  headers: {
@@ -100,9 +100,6 @@ const fetchAPI = async (info, init, getHeaders) => {
100
100
  }
101
101
  });
102
102
  if (response.ok) {
103
- if (getHeaders) {
104
- getHeaders(response.headers);
105
- }
106
103
  return response.status !== 204 ? response.json() : undefined;
107
104
  }
108
105
  console.error(info, init, response);
@@ -110,23 +107,12 @@ const fetchAPI = async (info, init, getHeaders) => {
110
107
  throw new Error(text);
111
108
  };
112
109
 
113
- function getCookieByName(cookiename, source) {
114
- var cookiestring = RegExp(cookiename + '=[^;]+').exec(source);
115
- return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, '') : '');
116
- }
117
-
118
110
  const BASE_INIT = {
119
111
  method: 'POST',
120
112
  headers: {
121
113
  'content-type': 'application/json'
122
114
  }
123
115
  };
124
- const setCheckoutOrderFormOwnershipCookie = (headers, ctx) => {
125
- if (headers) {
126
- var _headers$get;
127
- ctx.storage.cookies = `CheckoutOrderFormOwnership=${getCookieByName('CheckoutOrderFormOwnership', (_headers$get = headers.get('set-cookie')) != null ? _headers$get : '')}`;
128
- }
129
- };
130
116
  const VtexCommerce = ({
131
117
  account,
132
118
  environment,
@@ -201,7 +187,7 @@ const VtexCommerce = ({
201
187
  'content-type': 'application/json',
202
188
  cookie: ctx.headers.cookie
203
189
  }
204
- }, headers => setCheckoutOrderFormOwnershipCookie(headers, ctx));
190
+ });
205
191
  },
206
192
  orderForm: ({
207
193
  id,
@@ -215,7 +201,7 @@ const VtexCommerce = ({
215
201
  refreshOutdatedData: refreshOutdatedData.toString(),
216
202
  sc: salesChannel
217
203
  });
218
- return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT, headers => setCheckoutOrderFormOwnershipCookie(headers, ctx));
204
+ return fetchAPI(`${base}/api/checkout/pub/orderForm/${id}?${params.toString()}`, BASE_INIT);
219
205
  },
220
206
  updateOrderFormItems: ({
221
207
  id,
@@ -235,7 +221,7 @@ const VtexCommerce = ({
235
221
  noSplitItem: !shouldSplitItem
236
222
  }),
237
223
  method: 'PATCH'
238
- }, headers => setCheckoutOrderFormOwnershipCookie(headers, ctx));
224
+ });
239
225
  },
240
226
  setCustomData: ({
241
227
  id,
@@ -249,7 +235,7 @@ const VtexCommerce = ({
249
235
  value
250
236
  }),
251
237
  method: 'PUT'
252
- }, headers => setCheckoutOrderFormOwnershipCookie(headers, ctx));
238
+ });
253
239
  },
254
240
  region: async ({
255
241
  postalCode,
@@ -282,7 +268,7 @@ const VtexCommerce = ({
282
268
  cookie: ctx.headers.cookie
283
269
  },
284
270
  body: '{}'
285
- }, headers => setCheckoutOrderFormOwnershipCookie(headers, ctx));
271
+ });
286
272
  },
287
273
  subscribeToNewsletter: data => {
288
274
  return fetchAPI(`${base}/api/dataentities/NL/documents/`, {