mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Fixed include option not working for fetching tiers via #get
helper
refs https://github.com/TryGhost/Team/issues/1004 The output serializer for product was not handling `include` option value as comma separated string, which is passed via `#get` helper to fetch related prices for tiers. This change fixes the handling to work with both array as well as comma-separated include values.
This commit is contained in:
parent
eac732f620
commit
a328e3e88b
@ -1,6 +1,7 @@
|
||||
//@ts-check
|
||||
const debug = require('@tryghost/debug')('api:canary:utils:serializers:output:products');
|
||||
const _ = require('lodash');
|
||||
const utils = require('../../../../shared/utils');
|
||||
|
||||
const allowedIncludes = ['stripe_prices', 'monthly_price', 'yearly_price'];
|
||||
|
||||
@ -22,7 +23,7 @@ module.exports = {
|
||||
*/
|
||||
function paginatedProducts(page, _apiConfig, frame) {
|
||||
const requestedQueryIncludes = frame.original && frame.original.query && frame.original.query.include && frame.original.query.include.split(',') || [];
|
||||
const requestedOptionsIncludes = frame.original && frame.original.options && frame.original.options.include || [];
|
||||
const requestedOptionsIncludes = utils.options.trimAndLowerCase(frame.original && frame.original.options && frame.original.options.include || []);
|
||||
return {
|
||||
products: page.data.map((model) => {
|
||||
return cleanIncludes(
|
||||
|
@ -3,6 +3,7 @@ const debug = require('@tryghost/debug')('api:canary:utils:serializers:output:ti
|
||||
const _ = require('lodash');
|
||||
|
||||
const allowedIncludes = ['monthly_price', 'yearly_price'];
|
||||
const utils = require('../../../../shared/utils');
|
||||
|
||||
module.exports = {
|
||||
browse: createSerializer('browse', paginatedTiers),
|
||||
@ -22,7 +23,7 @@ module.exports = {
|
||||
*/
|
||||
function paginatedTiers(page, _apiConfig, frame) {
|
||||
const requestedQueryIncludes = frame.original && frame.original.query && frame.original.query.include && frame.original.query.include.split(',') || [];
|
||||
const requestedOptionsIncludes = frame.original && frame.original.options && frame.original.options.include || [];
|
||||
const requestedOptionsIncludes = utils.options.trimAndLowerCase(frame.original && frame.original.options && frame.original.options.include || []);
|
||||
return {
|
||||
tiers: page.data.map((model) => {
|
||||
return cleanIncludes(
|
||||
|
Loading…
Reference in New Issue
Block a user