Create new note in listing now working
This commit is contained in:
parent
93f9979259
commit
031a4e5259
3 changed files with 23 additions and 45 deletions
|
|
@ -15,9 +15,13 @@ export class StrapiNoteRepository implements NoteRepository {
|
|||
|
||||
private constructor() {}
|
||||
|
||||
private currentNoteId: number | undefined;
|
||||
private _currentNoteId: number | undefined;
|
||||
private static apiNoteEndpoint: string = "http://localhost:1337/api/notes"
|
||||
|
||||
public set currentNoteId(value: number | undefined) {
|
||||
this._currentNoteId = value;
|
||||
}
|
||||
|
||||
public async getNotes(): Promise<Note[]>{
|
||||
const response = await StrapiNoteRepository.fetchStrapiNoteEndpoint("/", 'GET');
|
||||
return await response.json();
|
||||
|
|
@ -29,10 +33,10 @@ export class StrapiNoteRepository implements NoteRepository {
|
|||
}
|
||||
|
||||
public async getCurrentNote(): Promise<Note | void> {
|
||||
if (this.currentNoteId === null || this.currentNoteId === undefined) {
|
||||
if (this._currentNoteId === null || this._currentNoteId === undefined) {
|
||||
return;
|
||||
}
|
||||
return await this.getNote(this.currentNoteId);
|
||||
return await this.getNote(this._currentNoteId);
|
||||
}
|
||||
|
||||
public async updateNote(id: number, note: Partial<Note>): Promise<Note> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue