I'm encountering an issue while attempting to send a request via Axios and specifying request headers using types. Unfortunately, I am running into an error.
To address this, I have defined an interface called Headers and utilized it to declare a variable this._apiHeaders
.
Below is the error message:
The "Headers" type cannot be assigned to the "AxiosRequestHeaders" type.
There is no index signature for the "string" type in the "Headers" type (ts2322)
interface Headers {
'X-Parse-Application-Id': string,
'X-Parse-REST-API-Key': string
}
const response: ITest = await axios.get(
this.formCorrectApiUrl(Endpoints.classes, DBObjectName),
{
headers: this._apiHeaders // This is where the error occurs
}
);
I would appreciate any assistance in resolving this error and understanding why it is happening.