UserRepo Working

This commit is contained in:
s-prechtl 2022-10-13 08:54:24 +02:00
parent bee5b04441
commit 6fd7726ae0
2 changed files with 14 additions and 3 deletions

View file

@ -71,7 +71,7 @@ export class StrapiNoteRepository implements NoteRepository {
}
static getAuthorizationHeader() {
const jwt = parseCookies().jwt;
const jwt = parseCookies('/').jwt;
return `bearer ${jwt}`
}
}

View file

@ -64,13 +64,24 @@ export class StrapiUserRepo implements UserRepository {
let requestInit: RequestInit = {
method: method,
};
if (authorization){
if (authorization && body) {
requestInit["headers"] = {
authorization: StrapiNoteRepository.getAuthorizationHeader() ?? '',
'Accept': 'application/json',
'Content-Type': 'application/json'
}
} else if (authorization){
requestInit["headers"] = {
authorization: StrapiNoteRepository.getAuthorizationHeader() ?? '',
}
} else if (body) {
requestInit["headers"] = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}
if (body) {
requestInit["body"] = JSON.stringify({data: body});
requestInit["body"] = JSON.stringify(body)
}
return await fetch((customPath) ? (this.api + customPath + path) : StrapiUserRepo.apiUserEndpoint + path, requestInit);
}