Skip to content

Commit

Permalink
⏪️ reverserer kall for søknader
Browse files Browse the repository at this point in the history
Co-authored-by: Tor Idland <[email protected]>
  • Loading branch information
thomasrognes and tidnav committed Jan 25, 2024
1 parent 519210a commit 93a6e11
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pages/api/soknader/soknader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ import metrics from 'lib/metrics';

const handler = beskyttetApi(async (req, res) => {
const accessToken = getAccessTokenFromRequest(req);
const søknader = await getSøknader(accessToken);
const params = {};
const søknader = await getSøknader(params, accessToken);
res.status(200).json(søknader);
});

export const getSøknader = async (accessToken?: string) => {
export const getSøknader = async (params: Record<string, string>, accessToken?: string) => {
if (isMock()) return mockSøknader;
const urlParams = Object.entries(params)
.map(([key, value]) => `${key}=${value}`)
.join('&');
const søknader = await tokenXApiProxy({
url: `${process.env.INNSENDING_URL}/innsending/søknader`,
url: `${process.env.SOKNAD_API_URL}/oppslag/soeknader${urlParams ? '?' + urlParams : ''}`,
prometheusPath: '/oppslag/soeknader',
method: 'GET',
audience: process.env.INNSENDING_AUDIENCE ?? '',
audience: process.env.SOKNAD_API_AUDIENCE ?? '',
bearerToken: accessToken,
logger: logger,
metricsStatusCodeCounter: metrics.backendApiStatusCodeCounter,
Expand Down

0 comments on commit 93a6e11

Please sign in to comment.