# API

Vue.js API 包含以下类目:

# JSONPlaceholder (opens new window)

fetch('https://jsonplaceholder.typicode.com/posts/1')
  .then((response) => response.json())
  .then((json) => console.log(json));
1
2
3
const getTodo = async () => {
  const res = await fetch('https://jsonplaceholder.typicode.com/posts/1') //async/await promise->object
  const data = await res.json() 
  console.log(data)
}
1
2
3
4
5
{
  id: 1,
  title: '...',
  body: '...',
  userId: 1
}
1
2
3
4
5
6