Skip to content

Commit

Permalink
Fix the error of using toString() when the versionCode is null.
Browse files Browse the repository at this point in the history
  • Loading branch information
GoneTone committed Sep 24, 2021
1 parent 1546713 commit 27bc393
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/GooglePlayAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,19 +362,21 @@ class GooglePlayAPI {
// noinspection JSUnresolvedVariable
const versionCode = appDetails.details.appDetails.versionCode

await this.purchase(packageName, offerType, versionCode)
const appDelivery = await this.appDelivery(packageName, offerType, versionCode)
if (versionCode) {
await this.purchase(packageName, offerType, versionCode)
const appDelivery = await this.appDelivery(packageName, offerType, versionCode)

// noinspection JSUnresolvedVariable
if (appDelivery.appDeliveryData === null) {
return false
// noinspection JSUnresolvedVariable
if (appDelivery.appDeliveryData !== null) {
// noinspection JSUnresolvedVariable
return appDelivery.appDeliveryData
}
}

// noinspection JSUnresolvedVariable
return appDelivery.appDeliveryData
} catch (e) {
throw Error(`Get "${packageName}" Download Info Failed: ${(typeof e.response !== 'undefined') ? e.response.data : e.message}`)
}

throw Error(`Get "${packageName}" download info failed, may be the device does not support.`)
}

/**
Expand Down

0 comments on commit 27bc393

Please sign in to comment.