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:
parent
5d25790d95
commit
7fa4b76c52
|
@ -35,10 +35,14 @@ export const controls = {
|
||||||
} );
|
} );
|
||||||
} )
|
} )
|
||||||
.catch( ( errorResponse ) => {
|
.catch( ( errorResponse ) => {
|
||||||
|
if ( typeof errorResponse.json === 'function' ) {
|
||||||
// Parse error response before rejecting it.
|
// Parse error response before rejecting it.
|
||||||
errorResponse.json().then( ( error ) => {
|
errorResponse.json().then( ( error ) => {
|
||||||
reject( error );
|
reject( error );
|
||||||
} );
|
} );
|
||||||
|
} else {
|
||||||
|
reject( errorResponse.message );
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue