I am trying to pass data from a php array to my created Gutenberg block. I need this data to populate a select inspector control. Right now im using the wp rest api and fetching the data inside the array. However this method is very slow and I am wondering if there is a faster approach to getting this data. I only need the data when i create the inspector controls for the block.
let options = [];
options.push({ value: -1, label: 'Select a template' });
wp.apiFetch({
path: 'adf/v1/blocks/hero-block',
}).then(data => {
var templates = JSON.parse(data);
templates.forEach((template) => {
options.push({ value: template, label: template });
});
});