CORS Error Fix for Chrome Extension

Job ID: 38257376

Budget: $15 – $25 USD

I have a chrome extension that is only 25 lines of code. I'm getting a CORS error when sending data to the API endpoint. The API endpoint does have access headers allowed. I just need the data to send to the API. The CORS error should be very quick to solve for someone that knows chrome extensions well.

let divContent = '';
let divElement = document.getElementById('orders_list_overlay_div');
if (divElement)
{
dataToSend = divElement.innerHTML;

fetch('*** api endpoint ***', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(dataToSend)
})
.then(response => response.json())
.then(data => {
console.log('API response:', data);
sendResponse({ success: true, response: data });
})
.catch(error => {
console.error('Error sending data to API:', error);
sendResponse({ success: false, error: error.message });
});
}