I've encountered some challenges while working on a contact form using Angular Reactive Forms and HttpClient for post requests. There seems to be an issue with the FormData append part, as I'm receiving an error message stating "Object is possibly 'null'" for the three formData.appends I've used.
Has anyone encountered a similar problem or have any insights on how to resolve this issue?
Here is the component code:
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { MessageService } from 'primeng/api';
@Component({
selector: 'app-contact',
templateUrl: './contact.component.html',
styleUrls: ['./contact.component.scss']
})
export class ContactComponent implements OnInit {
// Component code here
}
Below is the HTML code for the component:
<section id="contact">
<div class="main">
<!-- HTML code for contact form goes here -->
</div>
</section>
And here's the App Module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
// Other imports and declarations go here
@NgModule({
// App Module contents go here
})
export class AppModule {
}