> For the complete documentation index, see [llms.txt](https://kasperisme.gitbook.io/carnot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kasperisme.gitbook.io/carnot/guides/forbind-til-api/js-ts.md).

# JS/ TS

{% code lineNumbers="true" %}

```javascript
// Eksempel på integration i axios, NextJS-TS

import { useQuery } from "react-query";
import axios from "axios";

interface inputProps {
  daysahead: number;
  pricearea: string;
  energysource: string;
}

const getPrediction = async ({
  daysahead,
  energysource,
  pricearea,
}: inputProps) => {
  const { data } = await axios.get(
    `${process.env.NEXT_PUBLIC_API_BASE}/openapi/get_predict`,
    {
      params: {
        daysahead: daysahead,
        energysource: energysource,
        region: pricearea,
      },
      headers: {
        "apikey": `{{ api-key }}`,
        "username": `{{ username }}`,
      },
    }
  );

  return data;
};

function usePrediction({ daysahead, pricearea, energysource }: inputProps) {
  return useQuery(["prediction", pricearea, energysource, daysahead], () =>
    getPrediction({ daysahead, energysource, pricearea })
  );
}

export default usePrediction;

```

{% endcode %}
