vlab-research / fly

The Fly Survey platform
Other
2 stars 3 forks source link

Create a GET all endpoint for survey responses in json #111

Closed sssoja closed 2 years ago

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
fly ❌ Failed (Inspect) Jun 1, 2022 at 4:17PM (UTC)
netlify[bot] commented 2 years ago

Deploy Preview for vlab-research canceled.

Name Link
Latest commit a34f9145b44b1052e597b50833a5bb8d21837dbe
Latest deploy log https://app.netlify.com/sites/vlab-research/deploys/62d193f6f0412f0008003da9
netlify[bot] commented 2 years ago

Deploy Preview for virtuallab-videos canceled.

Name Link
Latest commit a34f9145b44b1052e597b50833a5bb8d21837dbe
Latest deploy log https://app.netlify.com/sites/virtuallab-videos/deploys/62d193f6606f770008e33216
nandanrao commented 2 years ago

Take a look at the line reference in the trace -> line 36. It's the this.query - remember that this is supposed to be an instance of the Pool class from node-pg, elsewhere in the code. So probably you need to make sure you have a pool there as well.

sssoja commented 2 years ago

Take a look at the line reference in the trace -> line 36. It's the this.query - remember that this is supposed to be an instance of the Pool class from node-pg, elsewhere in the code. So probably you need to make sure you have a pool there as well.

I updated the all function which is currently binded to pool so that it passes this as a param to the _all query. I then reference that instance as a param called pool in the _all query. I now get a different error pool.query is not a function rather than this reading as undefined.

In trying to isolate, I logged out pool and I get the name of the survey Survey123 but nothing else. I've been reading up on pooling from the node-postgres docs, specifically pool.query and as far as I can see the implementation is correct:

const { Pool } = require('pg')
const pool = new Pool()
pool
  .query(QUERY)

So I'm wondering if I've got my use of this and pool muddled...

nandanrao commented 2 years ago

Looking good!

sssoja commented 2 years ago

@nandanrao I just pushed a few more commits to reflect the changes discussed in standup.

I added a try-catch() to the all() function and refactored the error message to one generic RequestError so as to not get distracted by missing users credentials.

I'm just stuck on an error in my tests for surveyNotFound and userNotFound where my res is returning undefined. Might just need to look at it with fresh eyes but let me know if you can spot where I'm going wrong.