Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Replace stringify query with addQueryArgs (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu authored Jul 10, 2019
1 parent 470e535 commit 6325809
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions assets/js/blocks/reviews-by-product/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* External dependencies
*/
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';
import classNames from 'classnames';
import { Component } from '@wordpress/element';
import { debounce } from 'lodash';
import PropTypes from 'prop-types';
import { stringifyQuery } from '@woocommerce/navigation';

/**
* Internal dependencies
Expand Down Expand Up @@ -49,10 +49,12 @@ class ReviewsByProduct extends Component {
return;
}

const payload = stringifyQuery( { order_by: orderby, per_page: perPage, product: productId } );

apiFetch( {
path: `/wc/v3/products/reviews${ payload }`,
path: addQueryArgs( `/wc/v3/products/reviews`, {
order_by: orderby,
per_page: perPage,
product: productId,
} ),
} )
.then( ( reviews ) => {
this.setState( { reviews } );
Expand Down
2 changes: 1 addition & 1 deletion src/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function register_assets() {
self::register_script( 'wc-blocks', plugins_url( 'build/blocks.js', __DIR__ ), array(), false );
self::register_script( 'wc-vendors', plugins_url( 'build/vendors.js', __DIR__ ), array(), false );
self::register_script( 'wc-packages', plugins_url( 'build/packages.js', __DIR__ ), array(), false );
self::register_script( 'wc-frontend', plugins_url( 'build/frontend.js', __DIR__ ), array( 'wc-vendors', 'wc-packages' ) );
self::register_script( 'wc-frontend', plugins_url( 'build/frontend.js', __DIR__ ), array( 'wc-vendors' ) );

// Individual blocks.
self::register_script( 'wc-handpicked-products', plugins_url( 'build/handpicked-products.js', __DIR__ ), array( 'wc-vendors', 'wc-packages', 'wc-blocks' ) );
Expand Down

0 comments on commit 6325809

Please sign in to comment.