Fix getTotalFromResponse treating total 0 as undefined.

If total is 0, then the function should return 0, not undefined.
This commit is contained in:
Gan Eng Chin 2023-03-02 01:13:42 +08:00
parent 8e9f344478
commit b83888577a
No known key found for this signature in database
GPG Key ID: 94D5D972860ADB01
1 changed files with 7 additions and 3 deletions

View File

@ -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 ) {