Skip to content

Commit

Permalink
tester ut If-Match, del av HTTP-standard for optimistic locking
Browse files Browse the repository at this point in the history
  • Loading branch information
di0nys1us committed Nov 28, 2024
1 parent 0cd00a4 commit 2456e1a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/src/io/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const save = async (url: string, method: string, data: any, headers?: Headers):
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
},
body: JSON.stringify(data),
body: data == null ? null : JSON.stringify(data),
})
if (!response.ok) {
const message = await getErrorMessage(response)
Expand Down Expand Up @@ -186,15 +186,15 @@ export const postTildeling = async (sakId: number | string, overtaHvisTildelt: b

// Nytt oppgave API
export const postOppgaveTildeling = async (oppgaveId: string, versjon: number = -1) => {
return post(`${baseUrl}/api/oppgaver-v2/${oppgaveId}/tildeling`, { versjon })
return post(`${baseUrl}/api/oppgaver-v2/${oppgaveId}/tildeling`, null, { 'If-Match': `"${versjon}"` })
}

export const putOppdaterStatus = async (sakId: number | string, nyStatus: OppgaveStatusType) => {
return put(`${baseUrl}/api/sak/${sakId}/status`, { status: nyStatus })
}

export const postJournalføringStartet = async (oppgaveId: string, versjon: number = -1) => {
return post(`${baseUrl}/api/oppgaver-v2/${oppgaveId}/tildeling`, { versjon })
return post(`${baseUrl}/api/oppgaver-v2/${oppgaveId}/tildeling`, null, { 'If-Match': `"${versjon}"` })
}

export const postJournalføring = async (journalføringRequest: JournalføringRequest) => {
Expand All @@ -214,7 +214,7 @@ export const putOppdaterVilkår = async (
}

export const deleteFjernOppgaveTildeling = async (oppgaveId: string, versjon: number = -1) => {
return del(`${baseUrl}/api/oppgaver-v2/${oppgaveId}/tildeling`, { versjon })
return del(`${baseUrl}/api/oppgaver-v2/${oppgaveId}/tildeling`, null, { 'If-Match': `"${versjon}"` })
}

export const deleteFjernTildeling = async (sakId: number | string) => {
Expand Down

0 comments on commit 2456e1a

Please sign in to comment.