Skip to content

Commit b3a1dfd

Browse files
authored
Merge pull request #58
Add Authorization header to settings API requests
2 parents 29021b0 + 3152628 commit b3a1dfd

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

frontend/src/stores/settings.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export async function updateSettingsAPI(settings: UserSettings) {
5151

5252
const res = await fetch(`${API_BASE_URL}/api/settings/${oldUsername}`, {
5353
method: 'PATCH',
54-
headers: {'Content-Type': 'application/json'},
54+
headers: {
55+
'Authorization': `Bearer ${localStorage.getItem('token') as string}`,
56+
'Content-Type': 'application/json'
57+
},
5558
body: JSON.stringify(settings)
5659
})
5760

@@ -78,7 +81,11 @@ export async function resetSettingsAPI() {
7881

7982
const user_name = parseJwt(token).username;
8083
const res = await fetch(`${API_BASE_URL}/api/settings/reset/${user_name}`, {
81-
method: 'DELETE'
84+
method: 'DELETE',
85+
headers: {
86+
'Authorization': `Bearer ${localStorage.getItem('token') as string}`,
87+
'Content-Type': 'application/json'
88+
},
8289
})
8390

8491
if (res.ok) {

0 commit comments

Comments
 (0)