Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Convert curl request with array of objects to JS axios or fetch request

i'm trying to convert this request :

curl https://api.stripe.com/v1/payment_links \
  -u sk_test_dsgsdgsdgsdgsdyhwetdshsdhsdhsdhsdh: \
  -d "line_items[0][price]"=price_1K7o9TFRZ3JYnODMxojDKSWp \
  -d "line_items[0][quantity]"=1

to axios request : My array

const arrayOfPrices = [
    { price: 'price_1K7nrWFwZ3JYnODMD6Bb3SEy', quantity: 1 },
  ];

I have tried :

 console.log(
    new URLSearchParams({
      arrayOfPrices,
    })
  );
  return axios({
    method: 'post',
    url: 'https://api.stripe.com/v1/payment_links',
    headers: {
      Authorization: `Bearer ${process.env.STRIPE_PUBLIC_KEY}`,
      Accept: 'application/json',
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: new URLSearchParams({
      line_items: arrayOfPrices,
    })
  })
    .then((res) => res.data)
    .catch((err) => {
      console.log(err.response.data);
      return { status: 'fail', message: err.message };
    });

And more different sets but it doesn't work.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!