Im trying to get a json file using a service with angular 4
Service
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { CONFIG as APP_CONSTANTS } from '../config/config';
import 'rxjs/add/operator/map';
@Injectable()
export class SkillstreeService {
constructor(private http: Http) { }
public getSkills() {
return this.http.get('data/skillstree.json')
.map(res => {
res.json();
});
}
}
Component
import { SkillstreeService } from '../../services/skillstree.service';
constructor(public dialog: MatDialog, private skillService: SkillstreeService) {
this.getMageSkill();
}
public getMageSkill(): void {
this.skillService.getSkills().subscribe(res => {
console.log(res);
});
}
but for some reason is sending the 404 to the console, the json file is inside of src/app/data/skillstree.json any idea.
http://localhost:4200/app/data/skillstree.json