Skip to content

Commit 370f786

Browse files
committed
fix 403 Network Error handling
1 parent 5cfdedf commit 370f786

5 files changed

+28
-24
lines changed

dist/infinite-scroll.pkgd.js

+23-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Infinite Scroll PACKAGED v4.0.0
2+
* Infinite Scroll PACKAGED v4.0.1
33
* Automatically add next page
44
*
55
* Licensed GPLv3 for open source use
@@ -844,26 +844,30 @@ proto.loadNextPage = function() {
844844
this.isLoading = true;
845845
if ( typeof fetchOptions == 'function' ) fetchOptions = fetchOptions();
846846

847-
let fetchPromise = fetch( path, fetchOptions ).then( ( response ) => {
848-
if ( !response.ok ) {
849-
let error = new Error( response.statusText );
850-
this.onPageError( error, path, response );
851-
return { response };
852-
}
853-
854-
return response[ responseBody ]().then( ( body ) => {
855-
let canDomParse = responseBody == 'text' && domParseResponse;
856-
if ( canDomParse ) {
857-
body = domParser.parseFromString( body, 'text/html' );
858-
}
859-
if ( response.status == 204 ) {
860-
this.lastPageReached( body, path );
861-
return { body, response };
862-
} else {
863-
return this.onPageLoad( body, path, response );
847+
let fetchPromise = fetch( path, fetchOptions )
848+
.then( ( response ) => {
849+
if ( !response.ok ) {
850+
let error = new Error( response.statusText );
851+
this.onPageError( error, path, response );
852+
return { response };
864853
}
854+
855+
return response[ responseBody ]().then( ( body ) => {
856+
let canDomParse = responseBody == 'text' && domParseResponse;
857+
if ( canDomParse ) {
858+
body = domParser.parseFromString( body, 'text/html' );
859+
}
860+
if ( response.status == 204 ) {
861+
this.lastPageReached( body, path );
862+
return { body, response };
863+
} else {
864+
return this.onPageLoad( body, path, response );
865+
}
866+
} );
867+
} )
868+
.catch( ( error ) => {
869+
this.onPageError( error, path );
865870
} );
866-
} );
867871

868872
this.dispatchEvent( 'request', null, [ path, fetchPromise ] );
869873

dist/infinite-scroll.pkgd.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Infinite Scroll v4.0.0
2+
* Infinite Scroll v4.0.1
33
* Automatically add next page
44
*
55
* Licensed GPLv3 for open source use

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "infinite-scroll",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"description": "Automatically add next page",
55
"main": "js/index.js",
66
"files": [

0 commit comments

Comments
 (0)