title: POST form to FormSubmit with HttpClient and Angular
body: <p><a href="https://formsubmit.io/" rel="nofollow noreferrer">FormSubmit</a> is super great for easy lightweight form submission. I am using it in my Angular app and attempting to POST the form with the <code>HttpClient</code>, but I just can't seem to get it right. I am guessing my POST url is wrong but I am at a loss figuring out what the correct method is. </p>
  
  <p>Here is my the <code>onSubmit</code> function: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  onSubmit() {
      this.submitted = true;
      if (this.contactForm.invalid) {
        return;
      } else {
          this.formSubmit.sendForm(JSON.stringify(this.contactForm.value));
      }
    }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here the <code>HttpClient</code> service: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  
  @Injectable({
    providedIn: 'root'
  })
  export class FormsubmitService {
    constructor(
      public httpClient: HttpClient
    ) { }
  
    sendForm(formData) {
      console.log('Form Data:', formData);
      this.httpClient.post('https://formsubmit.io/send/&lt;TOKEN HERE&gt;', formData)
        .subscribe(
          (response) =&gt; console.log("Response:", response), (error) =&gt; console.log("Error:", error));
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Error response: </p>
  
  <p><a href="https://i.stack.imgur.com/PtgJe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PtgJe.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/9NpDD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9NpDD.png" alt="enter image description here"></a></p>