I am new to Sping Boot, rest api and angular12,
I am running my program in vscode to call the back api and i get the error "Failed to load resource: the server responded with a status of 404 (Not Found)"
my codes: backend controller :
@RestController
@RequestMapping("/evaluationController/")
public class EvaluationController {
@Autowired
private EvaluationRepository evaluationrepository;
//get all evaluationsnotes
@CrossOrigin(origins = "http://localhost:4200/")
@GetMapping("/notes")
public List<EvaluationModel> getAllEvaluations(){
return evaluationrepository.findAll();
}
//post notes
@PostMapping("/notes")
public EvaluationModel createEvaluationNote(@RequestBody EvaluationModel evaluationNote) {
return evaluationrepository.save(evaluationNote);
}
}
My front end angular12 service
@Injectable({
providedIn: 'root'
})
export class EvaluationserviceService {
private baseUrl!: "http://localhost:8080/evaluationController/notes";
constructor(private httpClient: HttpClient) { }
httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
}
getEvaluationNotes():Observable<Evaluationotes[]>{
return this.httpClient.get<Evaluationotes[]>(`${this.baseUrl}`);
}
}
my typescript file
@Component({
selector: 'app-fin-evaluation',
templateUrl: './fin-evaluation.component.html',
styleUrls: ['./fin-evaluation.component.css']
})
export class FinEvaluationComponent implements OnInit {
evaluationNote!: Evaluationotes[];
constructor(private evaluationNoteService: EvaluationserviceService ) { }
ngOnInit(): void {
this.getAllNotes();
}
private getAllNotes(){
this.evaluationNoteService.getEvaluationNotes().subscribe(data=>{
this.evaluationNote = data;
});
}
}
Thank you!