-2
$ curl https://api.goclimate.com/v1/flight_footprint \
  -u YOUR_API_KEY: \
  -d 'segments[0][origin]=ARN' \
  -d 'segments[0][destination]=BCN' \
  -d 'segments[1][origin]=BCN' \
  -d 'segments[1][destination]=ARN' \
  -d 'cabin_class=economy' \
  -d 'currencies[]=SEK' \
  -d 'currencies[]=USD' \
  -G

This is the api: https://api.goclimate.com/docs

VLAZ
  • 26,331
  • 9
  • 49
  • 67
  • What have you tried, where are you stuck? You're expected to show some research effort or attempt at solving the problem yourself, when submitting a question to SO. – Cerbrus Sep 01 '23 at 08:19
  • I tried with Fetch, async/await but I receive an error 404 or 401. Of course my api key is correct. It's two days that I'm trying to resolve this issue – massi17 Sep 01 '23 at 08:21
  • We can't tell what went wrong with your attempt to convert it to fetch if we can't see your attempt. Please read [ask], in particular the part about providing a [mcve]. – Quentin Sep 01 '23 at 08:25
  • It would also be useful to know if you were using `fetch` in the browser (where (a) there is a useful Network tab in the developer tools that shows exactly what request you are making and (b) it is subject to the [Same Origin Policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) and will be making a [Preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request))) or `fetch` in Node.js or `fetch` somewhere else. – Quentin Sep 01 '23 at 08:28
  • This might help you: https://stackoverflow.com/questions/35038857/setting-query-string-using-fetch-get-request – bas080 Sep 01 '23 at 09:00

1 Answers1

-1

Your question posted are not that clear, but this answer may help you, try to using online CURL converter tools like this. from that tool you will get the result like below code, hope this answer help you.

fetch('https://api.goclimate.com/v1/flight_footprint?segments[0][origin]=ARN&segments[0][destination]=BCN&segments[1][origin]=BCN&segments[1][destination]=ARN&cabin_class=economy&currencies[]=SEK&currencies[]=USD', { 
headers: {
    'Authorization': 'Basic ' + btoa('YOUR_API_KEY:')
}});

If you still have problem, make sure your API-KEY are correct, and try to read official documentation of Javasript for fetching APIs.