I am encountering an issue with the value
fetchOptions: Readonly<HttpFetchOptionsWithPath>
and my attempt to overwrite one of its properties.
Here is the method I have tried:
((fetchOptions as Writable<HttpFetchOptionsWithPath>).headers as Writable<any>) = {
'new-value': '123',
...(fetchOptions.headers || {}),
};
Unfortunately, I am still receiving a
TypeError: Cannot assign to read only property 'headers' of object '#<Request>'
error.
The corresponding executed javascript code looks like this:
fetchOptions.headers = __assign({ 'new-value': '123' }, (fetchOptions.headers || {}));
Can anyone provide insights on what could be going wrong in my approach?