✏️
const apiUrl = "https://jsonplaceholder.typicode.com/todos"
interface Todo {
userId: number;
id: number:
title: string;
completed: boolean;
}
async function fetchTodos(): Promise<Todo[]> {
const response = await fetch(apiUrl);
const data = await response.json();
return data;
}
fetchTodos().then((todos) => todos.filter);
타입 추론에 의해 fetchTodos의 type이 Promise라는 것을 알 수 있다.