Skip to content

Commit

Permalink
move the invalid resopnse check to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
javamatte committed Jun 1, 2023
1 parent 3bcf7f8 commit 00c258d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions carriers/usps.js
Expand Up @@ -90,12 +90,12 @@ function USPS(options) {

if (err) {
return callback(err);
} else if (!data || (!data.Error && !data.TrackResponse)) {
} else if (!data) {
return callback(new Error('Invalid or missing TrackResponse'));
} else if (data.Error) {
// Invalid credentials or Invalid Tracking Number
return callback(new Error(data.Error.Description[0]));
} else if (data.TrackResponse.TrackInfo[0].Error) {
} else if (!data?.TrackResponse?.TrackInfo?.[0] || data.TrackResponse.TrackInfo[0].Error) {
// No Tracking Information
return callback(null, results);
}
Expand Down

0 comments on commit 00c258d

Please sign in to comment.