proxy config

This commit is contained in:
imelilabourne 2020-09-15 16:14:45 +08:00
parent de41871af7
commit 247c891a09
6 changed files with 37 additions and 8 deletions

28
db.json
View file

@ -1,16 +1,40 @@
{ {
"tasks": [ "tasks": [
{ {
"title": "Sleeping", "title": "configure proxy config",
"completed": false, "completed": false,
"editing": false, "editing": false,
"id": 1 "id": 1
}, },
{ {
"title": "Dancing all day", "title": "study routing",
"completed": false, "completed": false,
"editing": false, "editing": false,
"id": 2 "id": 2
},
{
"title": "go to the gym",
"completed": false,
"editing": false,
"id": 3
},
{
"title": "nap for 10 mins",
"completed": false,
"editing": false,
"id": 4
},
{
"title": "buy milk",
"completed": false,
"editing": false,
"id": 5
},
{
"title": "karaoke",
"completed": false,
"editing": false,
"id": 6
} }
] ]
} }

View file

@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve --proxy-config proxyconfig.json",
"build": "ng build", "build": "ng build",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",

7
proxyconfig.json Normal file
View file

@ -0,0 +1,7 @@
{
"/tasks":{
"target": "http://localhost:3000",
"secure": false,
"changeOrigin": true
}
}

View file

@ -43,7 +43,7 @@
<div>{{ remaining()}} uncompleted tasks</div> <div>{{ remaining()}} uncompleted tasks</div>
</div> </div>
<div *ngIf="atleastOneCompleted()"> <div *ngIf="atleastOneCompleted()">
<button class="btn btn-warning btn-block" (click) ="clearCompleted(); deleteCompleted(task)">Clear Completed</button> <button class="btn btn-warning btn-block" (click) ="clearCompleted()">Clear Completed</button>
<div class="alert alert-warning">You've selected an item</div> <div class="alert alert-warning">You've selected an item</div>
</div> </div>

View file

@ -124,9 +124,7 @@ export class TodoList{
this.tasks = this.tasks.filter(task => !task.completed); this.tasks = this.tasks.filter(task => !task.completed);
// this.todoService.deleteTask(tasks) // this.todoService.deleteTask(tasks)
// .subscribe(data => this.tasks.filter(task => { // .subscribe(data => this.tasks.filter(task => !task.completed))
// return task == data;
// }))
} }
selectAll():void{ selectAll():void{

View file

@ -3,7 +3,7 @@ import { Injectable } from "@angular/core";
import { Observable } from "rxjs"; import { Observable } from "rxjs";
import { Tasks } from "../models/todo-interface"; import { Tasks } from "../models/todo-interface";
import { map } from "rxjs/operators"; import { map } from "rxjs/operators";
const URL = 'http://localhost:3000/tasks'; const URL = '/tasks';
@Injectable() @Injectable()
export class TodoService{ export class TodoService{
constructor(private http: HttpClient){} constructor(private http: HttpClient){}