UserRepo Working
This commit is contained in:
parent
bee5b04441
commit
6fd7726ae0
2 changed files with 14 additions and 3 deletions
|
|
@ -71,7 +71,7 @@ export class StrapiNoteRepository implements NoteRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getAuthorizationHeader() {
|
static getAuthorizationHeader() {
|
||||||
const jwt = parseCookies().jwt;
|
const jwt = parseCookies('/').jwt;
|
||||||
return `bearer ${jwt}`
|
return `bearer ${jwt}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,13 +64,24 @@ export class StrapiUserRepo implements UserRepository {
|
||||||
let requestInit: RequestInit = {
|
let requestInit: RequestInit = {
|
||||||
method: method,
|
method: method,
|
||||||
};
|
};
|
||||||
if (authorization){
|
if (authorization && body) {
|
||||||
|
requestInit["headers"] = {
|
||||||
|
authorization: StrapiNoteRepository.getAuthorizationHeader() ?? '',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
} else if (authorization){
|
||||||
requestInit["headers"] = {
|
requestInit["headers"] = {
|
||||||
authorization: StrapiNoteRepository.getAuthorizationHeader() ?? '',
|
authorization: StrapiNoteRepository.getAuthorizationHeader() ?? '',
|
||||||
}
|
}
|
||||||
|
} else if (body) {
|
||||||
|
requestInit["headers"] = {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (body) {
|
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);
|
return await fetch((customPath) ? (this.api + customPath + path) : StrapiUserRepo.apiUserEndpoint + path, requestInit);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue