~/VibeHandbook
免费 PDF

04 · 05

一个真实的请求和响应

下面是一次真实的 调用从头到尾的样子——你的应用发出去的请求,以及它拿回来的

GET /forecast?city=London HTTP/1.1
Host: api.weather.com
Authorization: Bearer sk_live_8f4b2c... 
Accept: application/json
{
  "city": "London",
  "unit": "celsius",
  "current": {
    "temp": 14,
    "condition": "cloudy"
  },
  "forecast": [
    { "day": "Mon", "high": 16, "low": 9 },
    { "day": "Tue", "high": 18, "low": 11 }
  ]
}

那行 Authorization 就是下一个话题——也是最值得做对的那个。

想离线阅读?

免费下载整本书的 PDF 或 EPUB。