Skip to content

Commit 503a806

Browse files
committed
[#18] removed explicit fetch mode option and fallback to the default
1 parent 39271fb commit 503a806

7 files changed

Lines changed: 12 additions & 15 deletions

File tree

dist/pocketbase.cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.es.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/pocketbase.es.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.2.1",
2+
"version": "0.2.2",
33
"name": "pocketbase",
44
"description": "PocketBase JavaScript SDK",
55
"author": "Gani Georgiev <gani.georgiev@gmail.com>",

src/Client.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default class Client {
7373
* Sends an api http request.
7474
*/
7575
send(path: string, reqConfig: { [key: string]: any }): Promise<any> {
76-
const config = Object.assign({}, reqConfig);
76+
const config = Object.assign({ method: 'GET' }, reqConfig);
7777

7878
// serialize the body if needed and set the correct content type
7979
// note1: for FormData body the Content-Type header should be skipped
@@ -116,8 +116,8 @@ export default class Client {
116116
}
117117

118118
// handle auto cancelation for duplicated pending request
119-
if (config?.params?.$autoCancel !== false) {
120-
const cancelKey = config?.params?.$cancelKey || ((config.method || 'GET') + path);
119+
if (config.params?.$autoCancel !== false) {
120+
const cancelKey = config.params?.$cancelKey || ((config.method || 'GET') + path);
121121

122122
// cancel previous pending requests
123123
this.cancelRequest(cancelKey);
@@ -127,8 +127,8 @@ export default class Client {
127127
config.signal = controller.signal;
128128
}
129129
// remove the special cancellation params from the other valid query params
130-
delete config?.params?.$autoCancel;
131-
delete config?.params?.$cancelKey;
130+
delete config.params?.$autoCancel;
131+
delete config.params?.$cancelKey;
132132

133133
// build url + path
134134
let url = this.buildUrl(path);
@@ -143,10 +143,7 @@ export default class Client {
143143
}
144144

145145
// send the request
146-
return fetch(url, Object.assign({
147-
method: 'GET',
148-
mode: ('cors' as RequestMode),
149-
}, config))
146+
return fetch(url, config)
150147
.then(async (response) => {
151148
let data = {};
152149

0 commit comments

Comments
 (0)