Я запускаю в Angular 5, я хочу отобразить список городов из API JAX-RS, затем я получаю следующую ошибку:
Http-сообщение об ошибке для http://localhost:4200/api/:404 Не найдено
Здесь вы найдете мои файлы, с которыми я работаю:
ville.service.ts
import {Injectable} from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Ville } from '../models/ville.model';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
@Injectable()
export class VilleService {
constructor(private http:HttpClient) {}
private userUrl = '/api/';
public getVilles() {
return this.http.get<Ville[]>(this.userUrl);
}
public deleteVille(ville) {
return this.http.delete(this.userUrl + "/"+ ville.idVille);
}
public createVille(ville) {
return this.http.post<Ville>(this.userUrl, ville);
}
}
proxy.config.json
{
"/api/*": {
"target": "http://localhost:8080/QuickDep/Compagne",
"secure": false
}
}
in package.json
"start": "ng serve --proxy-config proxy.config.json",