diff --git a/client/lib/wpcom-undocumented/lib/undocumented.js b/client/lib/wpcom-undocumented/lib/undocumented.js index 3a8726e6c8269..5db402acd4725 100644 --- a/client/lib/wpcom-undocumented/lib/undocumented.js +++ b/client/lib/wpcom-undocumented/lib/undocumented.js @@ -349,29 +349,6 @@ Undocumented.prototype.validateDomainContactInformation = function ( ); }; -/** - * Get site specific details for WordPress.com products - * - * @param {Function} siteDomain The site slug - * @param {Function} fn The callback function - */ -Undocumented.prototype.getSiteProducts = function ( siteDomain, fn ) { - debug( '/sites/:site_domain:/products query' ); - - // the site domain could be for a jetpack site installed in - // a subdirectory. encode any forward slash present before making - // the request - siteDomain = encodeURIComponent( siteDomain ); - - return this._sendRequest( - { - path: '/sites/' + siteDomain + '/products', - method: 'get', - }, - fn - ); -}; - /** * Get a site specific details for WordPress.com plans * diff --git a/client/state/sites/products/actions.js b/client/state/sites/products/actions.js index 24a18d5b40624..022362584f850 100644 --- a/client/state/sites/products/actions.js +++ b/client/state/sites/products/actions.js @@ -40,29 +40,26 @@ export function fetchSiteProducts( siteId ) { siteId, } ); - return new Promise( ( resolve ) => { - wpcom.undocumented().getSiteProducts( siteId, ( error, data ) => { - if ( error ) { - debug( 'Fetching site products failed: ', error ); + return wpcom.req + .get( `/sites/${ siteId }/products` ) + .then( ( data ) => { + dispatch( fetchSiteProductsCompleted( siteId, data ) ); + } ) + .catch( ( error ) => { + debug( 'Fetching site products failed: ', error ); - const errorMessage = - error.message || - i18n.translate( - 'There was a problem fetching site products. Please try again later or contact support.' - ); + const errorMessage = + error.message || + i18n.translate( + 'There was a problem fetching site products. Please try again later or contact support.' + ); - dispatch( { - type: SITE_PRODUCTS_FETCH_FAILED, - siteId, - error: errorMessage, - } ); - } else { - dispatch( fetchSiteProductsCompleted( siteId, data ) ); - } - - resolve(); + dispatch( { + type: SITE_PRODUCTS_FETCH_FAILED, + siteId, + error: errorMessage, + } ); } ); - } ); }; }