I came across this code snippet:
axios.get<Response>(url)
.then(response => {
console.log(response.data);
}).catch(error => {
// handle error
console.log(error);
});
The JSON response I am receiving has fields that are not easily expressed in TypeScript:
{
"field:Type": "foo"
}
For example, there is a field name:Type
that contains a string value - in this case, it's "foo"
How can I map such a field in the Response
interface so that I can access it later?
interface Response {
myMappedField: string;
}