Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 29 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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 |