You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
657 B

import type { NextApiRequest, NextApiResponse } from 'next'
import db from '../../utils/db';
import { database } from 'firebase-admin';
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
try {
const { slug } = req.body;
const entries = await db.collection('questionnaire').get();
const entriesData = entries.docs.map(entry => entry.data());
const { id } = await db.collection('questionnaire').add({
...req.body,
created: new Date().toISOString(),
});
res.status(200).json({ id });
} catch (e) {
res.status(400).end();
}
}