Completed
Push — master ( eb6aec...09e565 )
by Daniel
26s queued 12s
created

src/pages/api/fetchNavJobs.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 28
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 19
mnd 0
bc 0
fnc 2
dl 0
loc 28
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A fetchNavJobs.ts ➔ fetchNavJobs 0 19 1
1
import type { NextApiRequest, NextApiResponse } from "next";
2
3
type Data = {
4
  name: string;
5
};
6
7
export default function fetchNavJobs(
8
  _req: NextApiRequest,
9
  res: NextApiResponse<Data>
10
) {
11
  // This could be replaced with Axios if wanted
12
  fetch(
13
    "https://arbeidsplassen.nav.no/public-feed/api/v1/ads?size=100&page=1",
14
    // 'https://arbeidsplassenx.navtet.no/public-feed/api/v1/ads?size=100&page=1', // <- Trigger error handler with this
15
    {
16
      method: "GET",
17
      headers: {
18
        Authorization: `Bearer ${process.env.REACT_APP_AUTH}`,
19
      },
20
      mode: "cors",
21
    }
22
  ).then((result) =>
23
    result.json().then((data) => {
24
      res.status(200).json(data.content);
25
    })
26
  );
27
}
28