I was using netlifys amazing serverless functions in development (localhost) and I was testing certain things with MongoDB as well.
During this process I file that I didn’t add and I deleted it…
It looked like it was generated by netlify and it has maps of the js serverless functions I made.
This was the error
After a little testing (commenting out lines) it appears the issue stems from
const { CPU } = require('../db_config/component_models.js')
When this line is commented out (and the const data = CPU(JSON.parse(event.body)) associated with it) the function works.
If I call the function directly (http://localhost:8888/.netlify/functions/components) I see undefined logged to the console. If I load the homepage http://localhost:8888 I see the following logged to the console.
{"title":"RTX 3090","description":"This graphics card hits harder than ever!\nIt is the latest and greatest!","specifications":{"cudaCoreCount":10164,"clockSpeed":"10Mhgz"},"price":1700}
Response with status 200 in 2 ms.
Request from ::1: POST /.netlify/functions/components
undefined
{"title":"RTX 3090","description":"This graphics card hits harder than ever!\nIt is the latest and greatest!","specifications":{"cudaCoreCount":10164,"clockSpeed":"10Mhgz"},"price":1700}