I'm doing the following to capitalize all keys of an object response:
getBudget: build.query<BudgetType, void>({
query: () => "budget",
providesTags: ["Budget"],
transformResponse: (response: BudgetType) => {
const deepCopy = {...response};
Object.keys(deepCopy).forEach((key) => key[0].toUpperCase() + key.slice(1));
console.log(deepCopy);
return deepCopy;
}
}),
Budget type:
export type BudgetType = {
bills: number | null ,
transportation: number | null ,
health: number | null ,
school: number | null ,
food: number | null ,
entertainment: number | null
}
But it's not working, unsure why