| Server IP : 3.93.235.159 / Your IP : 216.73.216.140 Web Server : Apache System : Linux ip-172-26-0-169 5.10.0-46-cloud-amd64 #1 SMP Debian 5.10.262-1 (2026-07-31) x86_64 User : bitnami ( 1000) PHP Version : 8.2.9 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/site-mailer/assets/js/globals/api/ |
Upload File : |
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';
import APIError from './exceptions/APIError';
export const wpV2Prefix = '/wp/v2';
export const elementorOneV1Prefix = '/elementor-one/v1';
class APIBase {
static async request( { path, data, method = 'POST' } ) {
try {
if ( 'GET' === method && ! path.startsWith( wpV2Prefix ) ) {
path = addQueryArgs( path, { sb_time: new Date().getTime() } );
}
const response = await apiFetch( {
path,
method,
data,
} );
if ( path.startsWith( wpV2Prefix ) || path.startsWith( elementorOneV1Prefix ) ) {
return response;
}
if ( ! response.success ) {
throw new APIError( response.data.message );
}
return response.data;
} catch ( e ) {
if ( e instanceof APIError ) {
throw e;
} else {
throw new APIError( e.message );
}
}
}
}
export default APIBase;