Prevent All Products block from crashing when error has no json method (https://github.com/woocommerce/woocommerce-blocks/pull/2269)

This commit is contained in:
Albert Juhé Lluveras 2020-04-22 12:09:20 +02:00 committed by GitHub
parent 5d25790d95
commit 7fa4b76c52
1 changed files with 8 additions and 4 deletions

View File

@ -35,10 +35,14 @@ export const controls = {
} ); } );
} ) } )
.catch( ( errorResponse ) => { .catch( ( errorResponse ) => {
// Parse error response before rejecting it. if ( typeof errorResponse.json === 'function' ) {
errorResponse.json().then( ( error ) => { // Parse error response before rejecting it.
reject( error ); errorResponse.json().then( ( error ) => {
} ); reject( error );
} );
} else {
reject( errorResponse.message );
}
} ); } );
} ); } );
}, },