File tree 3 files changed +12
-5
lines changed
3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,10 @@ When provided this value will be sent in the `Content-Type` header. When not pro
88
88
89
89
Adds additional headers to the request. ` X-CSRF-Token ` and ` Content-Type ` are automatically included.
90
90
91
+ ##### credentials
92
+
93
+ Specifies the ` credentials ` option. Default is ` same-origin ` .
94
+
91
95
##### query
92
96
93
97
Appends query parameters to the URL. Query params in the URL are preserved and merged with the query options.
Original file line number Diff line number Diff line change @@ -198,14 +198,13 @@ describe('header handling', () => {
198
198
expect ( request . fetchOptions . signal ) . toBe ( "signal" )
199
199
} )
200
200
201
- test ( 'has fixed credentials setting which cannot be changed' , ( ) => {
201
+ test ( 'has credentials setting which can be changed' , ( ) => {
202
202
let request
203
203
request = new FetchRequest ( "get" , "localhost" )
204
204
expect ( request . fetchOptions . credentials ) . toBe ( 'same-origin' )
205
205
206
- // has no effect
207
- request = new FetchRequest ( "get" , "localhost" , { credentials : "omit" } )
208
- expect ( request . fetchOptions . credentials ) . toBe ( 'same-origin' )
206
+ request = new FetchRequest ( "get" , "localhost" , { credentials : "include" } )
207
+ expect ( request . fetchOptions . credentials ) . toBe ( 'include' )
209
208
} )
210
209
211
210
describe ( 'csrf token inclusion' , ( ) => {
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ export class FetchRequest {
58
58
headers : this . headers ,
59
59
body : this . formattedBody ,
60
60
signal : this . signal ,
61
- credentials : 'same-origin' ,
61
+ credentials : this . credentials ,
62
62
redirect : this . redirect
63
63
}
64
64
}
@@ -147,6 +147,10 @@ export class FetchRequest {
147
147
return this . options . redirect || 'follow'
148
148
}
149
149
150
+ get credentials ( ) {
151
+ return this . options . credentials || 'same-origin'
152
+ }
153
+
150
154
get additionalHeaders ( ) {
151
155
return this . options . headers || { }
152
156
}
You can’t perform that action at this time.
0 commit comments