【发布时间】:2020-01-27 14:28:55
【问题描述】:
我去了 MDN 并阅读了有关 fetch API 的信息,它说:
You can also optionally pass in an init options object as the second argument
假设,我们有这个简单的登录功能:
const login = () => {
const requestOptions = {
method: "POST",
headers: { "Content-type": "application/json" },
body: JSON.stringify({ username, password })
}
return fetch(`apiUrl/users/authenticate`, requestOptions)
.then(res = res.json)
.then(data => console.log(data))
}
那么,request options 是 init 对象吗?
【问题讨论】:
标签: javascript fetch fetch-api