@hyper-fetch/core 7.5.0 → 7.5.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyper-fetch/core",
3
- "version": "7.5.0",
3
+ "version": "7.5.2",
4
4
  "description": "Cache, Queue and Persist your requests no matter if you are online or offline!",
5
5
  "author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
6
6
  "homepage": "https://hyperfetch.bettertyped.com/",
@@ -72,9 +72,10 @@ export const stringifyValue = (response: string | unknown): string => {
72
72
 
73
73
  export const getAdapterHeaders = (request: RequestInstance) => {
74
74
  const isFormData = hasWindow() && request.payload instanceof FormData;
75
+ const isObject = typeof request.payload === "object" && request.payload !== null;
75
76
  const headers: HeadersInit = {};
76
77
 
77
- if (!isFormData) headers["Content-Type"] = "application/json";
78
+ if (!isFormData && isObject) headers["Content-Type"] = "application/json";
78
79
 
79
80
  Object.assign(headers, request.headers);
80
81
  return headers as HeadersInit;
@@ -41,8 +41,9 @@ export const getAdapter = () =>
41
41
  onRequestProgress,
42
42
  onSuccess,
43
43
  }) => {
44
- const { method, client, endpoint } = request;
45
- const fullUrl = `${client.url}${endpoint}`;
44
+ const { method, client, endpoint, queryParams } = request;
45
+ const queryString = queryParams ? stringifyQueryParams(queryParams) : "";
46
+ const fullUrl = `${client.url}${endpoint}${queryString}`;
46
47
  const xhr = new XMLHttpRequest();
47
48
  xhr.timeout = defaultTimeout;
48
49
  const onAbort = () => xhr.abort();
@@ -45,7 +45,7 @@ export const getAdapter = () =>
45
45
  onRequestStart,
46
46
  onSuccess,
47
47
  }) => {
48
- const { method, client, endpoint } = request;
48
+ const { method, client, endpoint, queryParams } = request;
49
49
  const { url } = client;
50
50
  const httpClient = client.url.includes("https://") ? https : http;
51
51
  const options = {
@@ -69,7 +69,8 @@ export const getAdapter = () =>
69
69
  options.headers["Content-Length"] = Buffer.byteLength(JSON.stringify(payload));
70
70
  }
71
71
 
72
- const fullUrl = `${url}${endpoint}`;
72
+ const queryString = queryParams ? stringifyQueryParams(queryParams) : "";
73
+ const fullUrl = `${url}${endpoint}${queryString}`;
73
74
 
74
75
  const unmountListener = createAbortListener({
75
76
  status: 0,