Chris Bitoy
03/23/2022, 5:19 PM.env
file on github - I saved my db URL_STRINGS in my .env
, committed and pushed my changes to git. However, got a message from git that the info in my .env
file is exposed (see image). I have since destroyed the databases in question, but wondering if this is a bug cos its not supposed to act this wayMichael Marino
03/23/2022, 5:46 PM.gitignore
will not ignore already tracked files - see this stackoverflow post: https://stackoverflow.com/questions/45400361/why-is-gitignore-not-ignoring-my-files#:~:text=gitignore%20only%20ignores%20files%20that,rm%20%2D%2Dcached%20on%20them.Chris Bitoy
03/23/2022, 6:27 PM./pages/api/categories/subcategories.js
8:24 Error: Parsing error: /vercel/path0/pages/api/categories/subcategories.js: Unexpected reserved word 'await'. (8:24)
6 |
7 | const getSubCategories = async('/', (req, res) => {
> 8 | const subCategories = await prisma.subCategory.findMany();
| ^
9 | res.json(subCategories);
10 | });
11 | // Get one subCategory
This is my code:
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
// Get all subCategories
const getSubCategories = async('/', (req, res) => {
const subCategories = await prisma.subCategory.findMany();
res.json(subCategories);
});
// Get one subCategory
const getSubCategory = async('/:id', (req, res) => {
const { id } = req.params;
const subCategory = await prisma.subCategory.findOne({ where: { id } });
res.json(subCategory);
});
I was thinking I can await
inside of an async
function - no?Michael Marino
03/23/2022, 6:37 PMMichael Marino
03/23/2022, 6:38 PMimport { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
// Get all subCategories
const getSubCategories = async('/', async (req, res) => {
const subCategories = await prisma.subCategory.findMany();
res.json(subCategories);
});
// Get one subCategory
const getSubCategory = async('/:id', async (req, res) => {
const { id } = req.params;
const subCategory = await prisma.subCategory.findOne({ where: { id } });
res.json(subCategory);
});
Michael Marino
03/23/2022, 6:38 PMMichael Marino
03/23/2022, 6:39 PMIn order to usehttps://stackoverflow.com/questions/42299594/await-is-a-reserved-word-error-inside-async-function, the function directly enclosing it needs to be async.await