HEX
Server: Apache
System: Linux webm003.cluster123.gra.hosting.ovh.net 6.18.39-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Tue Jul 21 12:03:15 CEST 2026 x86_64
User: vanessatli (59366)
PHP: 5.4.45
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/vanessatli/www/wp-content/plugins/themeisle-companion/dashboard/src/utils/rest.js
/* global obfxDash */
import fetch from 'node-fetch';

export const requestData = async (
	route,
	simple = false,
	data = {},
	urlEncoded = false,
	method = 'POST'
) => {
	const options = {
		method,
		headers: {
			Accept: 'application/json',
			'Content-Type': urlEncoded
				? 'application/x-www-form-urlencoded'
				: 'application/json',
			'x-wp-nonce': obfxDash.nonce,
		},
	};

	if ('POST' === method) {
		options.body = urlEncoded ? data : JSON.stringify(data);
	}

	return await fetch(route, options).then((response) => {
		return simple ? response : response.json();
	});
};

export const get = (route, simple) => {
	return requestData(route, simple, {}, 'GET');
};

export const post = (route, data) => {
	return requestData(route, false, data, true);
};