javascript - Convert curl to ajax request -


simple question: there way convert curl ajax request?

curl -v https://api.mydomain.com/v1/oauth2/token \   -h "accept: application/json" \   -h "accept-language: en_us" \   -u "1d75wsz6y0sfdvsy9183ivxfyzp:eclusmeuk8e9ihi7zdvlf" \   -d "grant_type=client_credentials" 

while i'm quite sure -h, i've no idea of how specify -u , -d.

if use xmlhttprequest can use setrequestheader setting request headers (-h)

-u can done simple prepending credentials url: https://1d75wsz6y0sfdvsy9183ivxfyzp:eclusmeuk8e9ihi7zdvlf@api.mydomain.com/v1/oauth2/token

-d post body should first argument in .send(body)


Comments