I'm wondering, how URL, for PUT method, gets constructed by in memory web api, say suppose app/commentList/0 - here 0 is the id of comment in commentList.
Sample Code of service:
updateComment(data: any):Observable<any>{
const url = `${this.dataUrl}/${data.id}`;
return this.http.put(url, JSON.stringify(data), this.options)
.map(res => console.log(res))
}
Sample code of DB:
import { InMemoryDbService } from 'angular2-in-memory-web-api';
export class CommentsData implements InMemoryDbService {
createDb() {
let commentList = [
{ id:1, username: 'abc', comment: 'adfasdfasdf' },
{ id:2, username: 'rty', comment: 'qwerqewr' },
{ id:3, username: 'Zaw', comment: 'poiqwer' },
{ id:4, username: 'weew', comment: 'asdflkjmasd' }
];
return {commentList};
}
}
In updateComment() method, I'm just hitting url with id parameter, but what if, I want to pass any different parameter, like as 'name'?