import {Address} from './address.model';
export const get = async ():Promise<Address[]> => {
return await fetch(`${apiUrl}`)
.then(response => {
if (!response.ok) {
throw new Error(response.statusText)
}
return response.json() as Promise<Address[]>;
})
//--------------caling from
React.useEffect(() => {
let newArr: Address[] = get() ;
setEntities(newArr);
} , [])
//-------------throws following error: Type 'Promise<Address[]>' is missing the following properties from type 'Address[]': length, pop, push, concat, and 28 more. TS2740