Tools I am Using
- Windows 10
- Firebase (Firestore)
- Postman
- JavaScript, Express
- I'm learning from this video(https://www.youtube.com/watch?v=-vo7cu0xP4I)
Situation Description
I attempted to make a post request using Postman for testing purposes, but it is not working (Get requests are working fine). Does anyone know what might be causing this error? I have tried the test multiple times but the post function is not functioning correctly.
Console Output in Visual Studio
functions: Finished "api" in ~1s
> (node:28624) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
...
(Truncated for brevity)
Desired Outcome
I want to successfully create a data entry in Firestore by posting from Postman.
Index.js Code Snippet
const functions = require('firebase-functions');
// Firebase Admin SDK
const admin = require('firebase-admin');
admin.initializeApp();
const express = require('express');
const app = express();
app.get('/screams', (req, res) => {
...
});
exports.api = functions.https.onRequest(app);
app.post('/scream',(req, res) => {
...
});
My Cloud Firestore Database Snapshot
https://i.stack.imgur.com/RRWO1.png
Postman Test Screenshot