Dumb question, but I have an application working on the old Angular-cli, that needs to be moved to the new cli, but after all my efforts, still can't get it to work. I am aware that the json parsing is done for me, and the new imports, but still can't seem to get the application to be functional.
This is the old working code before I tweaked with it trying to migrate it and broke it:
import { Injectable } from '@angular/core';
import { Http, Headers } from '@angular/http';
import { Job } from './jobs';
import 'rxjs/add/operator/map'
@Injectable({
providedIn: 'root'
})
export class JobsService {
constructor(private http: Http) { }
//retrieving jobs
getJobs()
{
return this.http.get('http://localhost:3000/api/jobs')
.map(res => res.json());
}
//add job
addJob(newJob)
{
var headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.post('http://localhost:3000/api/jobs', newJob,{headers:headers})
.map(res => res.json());
}
//delete
deleteJob(id)
{
return this.http.delete('http://localhost:3000/api/jobs'+id)
.map(res => res.json());
}
}
Could someone help me out and perhaps describe to me slightly what I should be doing? Thanks!
I am aware that the json parsing is done for me, why are you still usingjson()then?