Fix swagger hub requests from wc-api (url vs. path).
This commit is contained in:
parent
d28eb0bcc9
commit
7aeb69916a
|
@ -39,18 +39,18 @@ function read( resourceNames, fetch = apiFetch ) {
|
||||||
const endpoint = typeEndpointMap[ prefix ];
|
const endpoint = typeEndpointMap[ prefix ];
|
||||||
const query = getResourceIdentifier( resourceName );
|
const query = getResourceIdentifier( resourceName );
|
||||||
|
|
||||||
let apiPath = NAMESPACE + '/reports/' + endpoint + stringifyQuery( query );
|
const fetchArgs = {
|
||||||
|
parse: false,
|
||||||
|
};
|
||||||
|
|
||||||
if ( swaggerEndpoints.indexOf( endpoint ) >= 0 ) {
|
if ( swaggerEndpoints.indexOf( endpoint ) >= 0 ) {
|
||||||
apiPath = SWAGGERNAMESPACE + 'reports/' + endpoint + stringifyQuery( query );
|
fetchArgs.url = SWAGGERNAMESPACE + 'reports/' + endpoint + stringifyQuery( query );
|
||||||
|
} else {
|
||||||
|
fetchArgs.path = NAMESPACE + '/reports/' + endpoint + stringifyQuery( query );
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch( {
|
const response = await fetch( fetchArgs );
|
||||||
parse: false,
|
|
||||||
path: apiPath,
|
|
||||||
} );
|
|
||||||
|
|
||||||
const report = await response.json();
|
const report = await response.json();
|
||||||
// TODO: exclude these if using swagger?
|
// TODO: exclude these if using swagger?
|
||||||
const totalResults = parseInt( response.headers.get( 'x-wp-total' ) );
|
const totalResults = parseInt( response.headers.get( 'x-wp-total' ) );
|
||||||
|
|
|
@ -40,22 +40,20 @@ function read( resourceNames, fetch = apiFetch ) {
|
||||||
const endpoint = typeEndpointMap[ prefix ];
|
const endpoint = typeEndpointMap[ prefix ];
|
||||||
const query = getResourceIdentifier( resourceName );
|
const query = getResourceIdentifier( resourceName );
|
||||||
|
|
||||||
let apiPath = endpoint + stringifyQuery( query );
|
const fetchArgs = {
|
||||||
|
parse: false,
|
||||||
|
};
|
||||||
|
|
||||||
if ( swaggerEndpoints.indexOf( endpoint ) >= 0 ) {
|
if ( swaggerEndpoints.indexOf( endpoint ) >= 0 ) {
|
||||||
apiPath = SWAGGERNAMESPACE + 'reports/' + endpoint + '/stats' + stringifyQuery( query );
|
fetchArgs.url = SWAGGERNAMESPACE + 'reports/' + endpoint + '/stats' + stringifyQuery( query );
|
||||||
}
|
} else if ( statEndpoints.indexOf( endpoint ) >= 0 ) {
|
||||||
|
fetchArgs.path = NAMESPACE + '/reports/' + endpoint + '/stats' + stringifyQuery( query );
|
||||||
if ( statEndpoints.indexOf( endpoint ) >= 0 ) {
|
} else {
|
||||||
apiPath = NAMESPACE + '/reports/' + endpoint + '/stats' + stringifyQuery( query );
|
fetchArgs.path = endpoint + stringifyQuery( query );
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch( {
|
const response = await fetch( fetchArgs );
|
||||||
parse: false,
|
|
||||||
path: apiPath,
|
|
||||||
} );
|
|
||||||
|
|
||||||
const report = await response.json();
|
const report = await response.json();
|
||||||
// TODO: exclude these if using swagger?
|
// TODO: exclude these if using swagger?
|
||||||
const totalResults = parseInt( response.headers.get( 'x-wp-total' ) );
|
const totalResults = parseInt( response.headers.get( 'x-wp-total' ) );
|
||||||
|
|
Loading…
Reference in New Issue