【发布时间】:2017-12-17 10:49:56
【问题描述】:
我正在尝试获取 curl 并从 API 获取 JSON。
curl -XPOST -d "grant_type=password" -d "username=admin@admin.admin" \
-d "password=admin" "web_app@localhost:8081/oauth/token"
当我在终端中使用 curl 时,一切正常,但尝试使用 fetch 时,我收到底部提到的错误消息。
fetch("http://web_app@localhost:8081/oauth/token", {
credentials: 'include',
body: "grant_type=password&username=admin@admin.admin&password=admin",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
method: "POST"
}
这是我得到的错误:
TypeError: http://web_app@localhost:8081/oauth/token 是一个带有 嵌入式凭据。
我做错了吗?
【问题讨论】:
标签: api reactjs curl fetch-api