updateStudent(userName: string, age: number): Observable<any> {
debugger;
let formData = new FormData();
let reqJson: any = {};
reqJson["userName"] = userName;
reqJson["age"] = age;
formData.append('info', JSON.stringify(reqJson));
return this.httpClient.post(this.url + '/update-student', formData);
}
... and I have this notation in my Java Spring Boot backend:
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/api")
public class HomeController {
This is an error that I get:
Access to XMLHttpRequest at 'http://localhost:8080/api/update-student' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.