I am currently working on creating a CRUD app using Angular6 with MSSQL.
I have successfully retrieved data from my local database and created the desired routes but I am having trouble displaying the data in the frontend.
//masterList.service.ts
import {
Injectable
} from '@angular/core';
import {
HttpClient
} from '@angular/common/http';
import {
MasterList
} from './MasterList';
@Injectable({
providedIn: 'root'
})
export class MasterListService {
uri = 'http://localhost:4000/masterList';
constructor(private http: HttpClient) {}
getMasterList() {
console.log(this);
return this
.http
.get(`${this.uri}/`);
}
}
//package.json
"name": "ng6crud",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "nodemon server.js && ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Running:
npm start
This returns the service with the data but the app is not compiled, and reversing the order does the opposite, with the error:
ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "http://localhost:4000/masterList/", ok: false, …}
How do I get data from my service: 4000
and have it published: 4200
at the same time?