Fix getTotalFromResponse treating total 0 as undefined.
If total is 0, then the function should return 0, not undefined.
This commit is contained in:
parent
8e9f344478
commit
b83888577a
|
@ -57,9 +57,13 @@ export function* getRecommendedChannels() {
|
|||
}
|
||||
|
||||
const getTotalFromResponse = ( response: Response ) => {
|
||||
return (
|
||||
parseInt( response.headers.get( 'x-wp-total' ) || '0', 10 ) || undefined
|
||||
);
|
||||
const total = response.headers.get( 'x-wp-total' );
|
||||
|
||||
if ( total === null ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return parseInt( total, 10 );
|
||||
};
|
||||
|
||||
export function* getCampaigns( page: number, perPage: number ) {
|
||||
|
|
Loading…
Reference in New Issue