I was looking through other posts for replacements for Curl in nodejs, especially with complex behaviors as such:
-H 'Authorization: Basic MjJCTUpROjczNzY0YzkwOWQ2MDczZDRjYzA0YWZhZDBlMDVhMThm' \
--data "clientId=22BMJQ" \
--data "grant_type=authorization_code" \
--data "redirect_uri=https%3A%2F%2Fexample.com%2Fcallback" \
--data "code=5f10eff73e8daf2049be22bb079beee57036c7a5" \
-H 'Content-Type: application/x-www-form-urlencoded' \
https://api.fitbit.com/oauth2/token
Are there any packages you would recommend or have ideas on how the above request could be replicated in nodejs?
In case you don't only want to call OAuth 2.0 endpoints but also other endpoints with the curl alternative, I made good experiences with node-fetch. The code with node-fetch is more readable and you can work with response very easily in JavaScript.