Skip to content
Advertisement

Firebase Functions cannot get request values sent from a simple contact form in Angular9

I am developing a simple contact form by using Angular9 + Firebase. I have no idea how to get the values from the contact form in the Firebase Function.

I tried it in many ways, but I always get the “undefined” value. The following is my code. Please give me the solution if anybody knows how to do. Thank you.

Frontend

JavaScript

When the submit button is clicked, contactJson looks like this:

JavaScript

Firebase Functions – index.ts

JavaScript

The following is the email body I receive. Each value is “undefined”.

JavaScript

In the end of the process, the google chrome console get the success message

JavaScript

Version Info

JavaScript

Advertisement

Answer

The way you’re gathering the information only works for the Content-Type of application/json, so first to determine if you’re indeed sending this specific content type, you can do that with request.get('content-type'):

JavaScript

Or by using this example on the documentation that emcompasses almos all types of HTTP requests:

JavaScript

The only type that seems to be missing is the case of Multipar-Form, this specific type could be done with this example on the documentation

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement