title: How to do and show server validation errors in angular form
body: <p>I'm new to angular. I was trying something and got stuck.
  In my form, I want to show server validation response as error coming from a laravel rest api. But don't know how to store and show it in the template. I am able to log it to the console but not able to move further with the error message.</p>
  <p><strong>The response is somewhat like this-</strong></p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;message&quot;: {
          &quot;firstname&quot;:[&quot;The firstname field is required.&quot;],
          &quot;lastname&quot;:[&quot;The lastname field is required.&quot;],
          &quot;email&quot;:[&quot;The email field is required.&quot;],
          &quot;password&quot;:[&quot;The password field is required.&quot;]
      }
  }
  </code></pre>
  <p><strong>The Service code:</strong></p>
  <pre class="lang-js prettyprint-override"><code>registerUser(user): Observable&lt;any&gt; {
      return this.http
        .post&lt;any&gt;(`${this.url}/register`, user)
        .pipe(map(res =&gt; res.message));
  }
  </code></pre>
  <p><strong>The register user method in component class:</strong></p>
  <pre class="lang-js prettyprint-override"><code>registerUser() {
      console.log(this.registrationForm.value);
      this.authService.registerUser(this.registrationForm.value).subscribe(
          res =&gt; console.log(res),
          err =&gt; console.log(err)
      );
  }
  </code></pre>
  <p>Also, correct me if I'm going wrong anywhere and how should I correct it</p>