Here is the data I receive through the API.
i_1: {count: 1, name: 'name1', price: 35000}
i_2: {count: 1, name: 'name2', price: 30000}
i_3: {count: 1, name: 'nam3', price: 30000}
I defined its type like this.
interface Item {
count: number;
name: String;
price: number;
}
I added that to a type property called Data.
interface Data {
items?: Item;
...etc
}
But I ran into a problem when I tried to use Object.entries.
code
Object.entries(items).map(([key, value]) => ())
The error message is :
No overload matches this call.
Overload 1 of 2, '(o: { [s: string]: unknown; } | ArrayLike<unknown>): [string, unknown][]', gave the following error.
Argument of type 'Item | undefined' is not assignable to parameter of type '{ [s: string]: unknown; } | ArrayLike<unknown>'.
Type 'undefined'enter code here is not assignable`enter code here` to type '{ [s: string]: unknown; } | ArrayLike<unknown>'.
Overload 2 of 2, '(o: {}): [string, any][]', gave the following error.
Argument of type 'Item | undefined' is not assignable to parameter of type '{}'.
Type 'undefined' is not assignable to type '{}'.
Any help would be appreciated.