Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
how to get error response from spring boot in angular

I have a method where I am sending values to my backend, so far saving works, now I want to make an error handling. But when I try to console.log my error I am getting back an undefined. I tried different things like consoling the error directly or first assigning it to a const, but it always returns an undefined. Could someone look at it and tell me where my error is?

uploadFile(files: FileList | null): void {
    const documents = this.documentArray;
    if (files) {
      const file = files.item(0);
      const reader = new FileReader();
      reader.readAsDataURL(file);
      reader.onload = () => {
        documents.filename = file.name;
        documents.base64 = "reader.result.slice(28).toString()";
        documents.documentType = this.form.controls.dokumentType.value;
        this.api.saveDocument({body:
        documents}).subscribe((res) =>{
          const data = res
          console.log("Here is your data: " + data) 
         }, (error: HttpErrorResponse) => {
           const err = error
           console.error("Here is your error: " + err.status)
         })
      };
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!