I'm trying to fetch a curl and get a JSON from an API.
curl -XPOST -d "grant_type=password" -d "[email protected]"
-d "password=admin" "web_app@localhost:8081/oauth/token"
When I use the curl in terminal everything works fine but trying it with a fetch I get the error message mentioned at the bottom.
fetch("http://web_app@localhost:8081/oauth/token", {
credentials: 'include',
body: "grant_type=password&[email protected]&password=admin",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
method: "POST"
}
This is the error I get:
TypeError: http://web_app@localhost:8081/oauth/token is an url with
embedded credentials.
Is the fetch I did wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…