Skip to content

Commit

Permalink
Create deleteNote method in client files
Browse files Browse the repository at this point in the history
Added deleteNote method in note.service.ts and owner-doorboard.component.ts. Closes issue #5
  • Loading branch information
Shawn Reuter committed Mar 29, 2020
1 parent d0859c6 commit c19a997
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/src/app/notes/note.service.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Observable, ObservableInput } from 'rxjs';
import { environment } from '../../environments/environment';
import { Note } from './note';
import { map } from 'rxjs/operators';

import { map, catchError } from 'rxjs/operators';
@Injectable()
export class NoteService {
readonly noteUrl: string = environment.API_URL + 'notes';
readonly ownerUrl: string = environment.API_URL + 'owner';
handleError: (err: any, caught: Observable<void>) => ObservableInput<any>;

constructor(private httpClient: HttpClient) {
}
Expand All @@ -32,4 +32,8 @@ export class NoteService {
return this.httpClient.post<{id: string}>
(this.ownerUrl + '/' + id + '/notes/new', newNote).pipe(map(res => res.id));
}

deleteNote(id: string): Observable<void> {
return this.httpClient.delete<void>('${this.baseUrl}/${id}');
}
}
6 changes: 6 additions & 0 deletions client/src/app/owners/owner-doorboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ export class OwnerDoorBoardComponent implements OnInit, OnDestroy {
}
}

deleteNote(){
this.noteService.deleteNote(this.id).subscribe(
() => console.log('Note with Id = ${this.id} deleted'),
(err) => console.log(err)
);
}
}

0 comments on commit c19a997

Please sign in to comment.