const response = await fetch('https://api.codetabs.com/v1/proxy/?quest=http://hamsterland.herokuapp.com/api/users?id=330746772378877954');
const json = await response.json();
const user: User = JSON.parse(json);
interface User {
id: string;
username: string;
avatar: string;
}
On the last line, JSON.parse(json), I receive an error that states:
Unhandled Rejection (SyntaxError): Unexpected token o in JSON at position 1
I am not sure what is causing this. The interface model matches the JSON structure.
.json()does.JSON.parse(object)it has to try to figure out what to do, so it to strings the object which turns intoJSON.parse('[object Object]')