简体   繁体   中英

Translate stripe Curl request to Axios

Hello I'd like to translate this to axios!

curl https://api.stripe.com/v1/subscriptions/search \
  -u sk_test_ReallyLongkey: \
  --data-urlencode query="status:'active' AND metadata['order_id']:'6735'" \
  -G

I attempted something like this but it doesn't seem to work

const request = await axios({
    method: 'POST',
    url: 'https://api.stripe.com/v1/subscriptions/search',
    auth: {
      user: process.env.STRIPE_SECERET,
      pass: '',
    },
    data: qs.stringify({
      status: 'active',
    }),
    headers: {
      'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
    },
  });

Thanks

you need to make a get request using Axios and use URL query parameters.

axios.get("https://api.stripe.com/v1/subscriptions/search",{
params:{status:"active"},
headers:{"authorization":`bearer ${myApiKey}`}
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM