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 ) => {
|
const getTotalFromResponse = ( response: Response ) => {
|
||||||
return (
|
const total = response.headers.get( 'x-wp-total' );
|
||||||
parseInt( response.headers.get( 'x-wp-total' ) || '0', 10 ) || undefined
|
|
||||||
);
|
if ( total === null ) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseInt( total, 10 );
|
||||||
};
|
};
|
||||||
|
|
||||||
export function* getCampaigns( page: number, perPage: number ) {
|
export function* getCampaigns( page: number, perPage: number ) {
|
||||||
|
|
Loading…
Reference in New Issue