File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
Expand file tree Collapse file tree 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
8888
8989Adds additional headers to the request. ` X-CSRF-Token ` and ` Content-Type ` are automatically included.
9090
91+ ##### credentials
92+
93+ Specifies the ` credentials ` option. Default is ` same-origin ` .
94+
9195##### query
9296
9397Appends 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', () => {
198198 expect ( request . fetchOptions . signal ) . toBe ( "signal" )
199199 } )
200200
201- test ( 'has fixed credentials setting which cannot be changed' , ( ) => {
201+ test ( 'has credentials setting which can be changed' , ( ) => {
202202 let request
203203 request = new FetchRequest ( "get" , "localhost" )
204204 expect ( request . fetchOptions . credentials ) . toBe ( 'same-origin' )
205205
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' )
209208 } )
210209
211210 describe ( 'csrf token inclusion' , ( ) => {
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ export class FetchRequest {
5858 headers : this . headers ,
5959 body : this . formattedBody ,
6060 signal : this . signal ,
61- credentials : 'same-origin' ,
61+ credentials : this . credentials ,
6262 redirect : this . redirect
6363 }
6464 }
@@ -147,6 +147,10 @@ export class FetchRequest {
147147 return this . options . redirect || 'follow'
148148 }
149149
150+ get credentials ( ) {
151+ return this . options . credentials || 'same-origin'
152+ }
153+
150154 get additionalHeaders ( ) {
151155 return this . options . headers || { }
152156 }
You can’t perform that action at this time.
0 commit comments