File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -20,25 +20,29 @@ export default function sendRequest(
20
20
queryParams = { } ,
21
21
relativeUrl ,
22
22
responseType = 'json' ,
23
- additionalHeaders = { }
23
+ additionalHeaders = { } ,
24
+ isGetRequest = false
24
25
) {
25
26
const headers = {
26
27
'Content-Type' : 'application/json' ,
27
28
Store : storeCode ,
28
29
...additionalHeaders ,
29
30
} ;
31
+ const method = isGetRequest ? 'GET' : 'POST' ;
30
32
const token = LocalStorage . getCustomerToken ( ) ;
31
33
const url = `${ config . baseUrl } ${ relativeUrl || '/graphql' } ` ;
32
34
33
35
if ( token ) {
34
36
headers . Authorization = `Bearer ${ token } ` ;
35
37
}
36
38
37
- return fetch ( url , {
38
- headers,
39
- method : 'POST' ,
40
- body : JSON . stringify ( { ...queryParams } ) ,
41
- } )
39
+ const fetchOptions = { headers, method } ;
40
+
41
+ if ( ! isGetRequest ) {
42
+ fetchOptions . body = JSON . stringify ( { ...queryParams } ) ;
43
+ }
44
+
45
+ return fetch ( url , fetchOptions )
42
46
. then ( ( response ) => {
43
47
if ( response . ok && responseType === RESPONSE_TEXT ) {
44
48
return response . text ( ) ;
You can’t perform that action at this time.
0 commit comments