File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,11 @@ let infScroll = new InfiniteScroll( '.container', {
8989 // enables parsing response body into a DOM
9090 // disable to load flat text
9191
92+ fetchOptions: undefined ,
93+ // sets custom settings for the fetch() request
94+ // for setting headers, cors, or POST method
95+ // can be set to an object, or a function that returns an object
96+
9297 outlayer: false ,
9398 // Integrates Masonry, Isotope or Packery
9499 // Appended items will be added to the layout
Original file line number Diff line number Diff line change @@ -149,9 +149,7 @@ proto.log = function( type, args ) {
149149
150150 let message = `[InfiniteScroll] ${ type } ` ;
151151 let logger = loggers [ type ] ;
152- if ( logger ) {
153- message += '. ' + logger . apply ( this , args ) ;
154- }
152+ if ( logger ) message += '. ' + logger . apply ( this , args ) ;
155153 console . log ( message ) ;
156154} ;
157155
Original file line number Diff line number Diff line change @@ -47,12 +47,13 @@ let domParser = new DOMParser();
4747proto . loadNextPage = function ( ) {
4848 if ( this . isLoading || ! this . canLoad ) return ;
4949
50- let { responseBody, domParseResponse } = this . options ;
50+ let { responseBody, domParseResponse, fetchOptions } = this . options ;
5151 let path = this . getAbsolutePath ( ) ;
5252 this . isLoading = true ;
53+ if ( typeof fetchOptions == 'function' ) fetchOptions = fetchOptions ( ) ;
5354
5455 // TODO add fetch options
55- let fetchPromise = fetch ( path ) . then ( ( response ) => {
56+ let fetchPromise = fetch ( path , fetchOptions ) . then ( ( response ) => {
5657 if ( ! response . ok ) {
5758 let error = new Error ( response . statusText ) ;
5859 this . onPageError ( error , path ) ;
You canβt perform that action at this time.
0 commit comments