Passed
Push — master ( 2a9974...92305b )
by Daniel
01:39 queued 11s
created

pages/api/fetchNavJobs.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 29
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 20
mnd 0
bc 0
fnc 2
dl 0
loc 29
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
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2
import type { NextApiRequest, NextApiResponse } from "next";
3
4
type Data = {
5
  name: string;
6
};
7
8
export default function fetchNavJobs(
9
  _req: NextApiRequest,
10
  res: NextApiResponse<Data>
11
) {
12
  // This could be replaced with Axios if wanted
13
  fetch(
14
    "https://arbeidsplassen.nav.no/public-feed/api/v1/ads?size=100&page=1",
15
    // 'https://arbeidsplassenx.navtet.no/public-feed/api/v1/ads?size=100&page=1', // <- Trigger error handler with this
16
    {
17
      method: "GET",
18
      headers: {
19
        Authorization: `Bearer ${process.env.REACT_APP_AUTH}`,
20
      },
21
      mode: "cors",
22
    }
23
  ).then((result) =>
24
    result.json().then((data) => {
25
      res.status(200).json(data.content);
26
    })
27
  );
28
}
29