Currently, I am working on a tutorial where we are building an Angular service to send emails from a form using the Mailthis Email API. In the code for the service, I encountered an error related to the 'api' variable that states "Property 'api' does not exist on type 'MyService'". Any guidance or suggestions would be greatly appreciated!
Here is a snippet of my code:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class MyService {
constructor(private http:HttpClient) { }
PostMessage(input:any){
return this.http.post(this.api, input, { responseType:'text' }).pipe(
map(
(response:any) => {
if(response){
return response;
}
},
(error:any) => {
return error;
}
)
)
}
}