mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
Handled missing Offer when reading
no-issue When attempting to read a non-existent offer we were running into issues with calling toJSON() on `null`. This updates the handling to explicitly return null - so that the controller can correctly throw a NotFoundError
This commit is contained in:
parent
b6234d6e96
commit
49f325dde4
@ -134,6 +134,10 @@ class OfferRepository {
|
||||
withRelated: ['product']
|
||||
});
|
||||
|
||||
if (!model) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.mapToOffer(model, options);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,10 @@ class OffersAPI {
|
||||
|
||||
const offer = await this.repository.getById(data.id, options);
|
||||
|
||||
if (!offer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return OfferMapper.toDTO(offer);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user