diff --git a/lib/theme-api-client.js b/lib/theme-api-client.js index 64d45f70..9c777434 100644 --- a/lib/theme-api-client.js +++ b/lib/theme-api-client.js @@ -208,11 +208,23 @@ async function getChannelActiveTheme({ accessToken, apiHost, storeHash, channelI */ async function getStoreChannels({ accessToken, apiHost, storeHash }) { try { - const response = await networkUtils.sendApiRequest({ + const sitesResponse = await networkUtils.sendApiRequest({ url: `${apiHost}/stores/${storeHash}/v3/sites`, accessToken, }); - return response.data.data; + const channelsResponse = await networkUtils.sendApiRequest({ + url: `${apiHost}/stores/${storeHash}/v3/channels`, + accessToken, + }); + + const storefrontChannels = channelsResponse.data.data.filter( + (channel) => channel.type === 'storefront', + ); + + return sitesResponse.data.data.filter( + (site) => + storefrontChannels.filter((channel) => channel.id === site.channel_id).length > 0, + ); } catch (err) { throw new Error(`Could not fetch a list of the store channels: ${err.message}`); }