Pets-without-names / Jax-Pet-Names

This project is a collaboration designed to create a pet naming web application.
MIT License
3 stars 2 forks source link

Slight changes to client API calls #13

Closed dopecello closed 1 year ago

dopecello commented 1 year ago

Changed how we're passing the React state variable to the backend.

What I noticed is that in the server/index.js directory, the getNames query in queries.js is being called via the localhost:3000/names endpoint. I guess that adding a url param is one way to go about it, but the one I know works is sending the state in the request.body. this also makes it easier to test via Postman or Insomnia.

I will come to the coffee shop this Tuesday. @murjax, I was wondering if you could edit the README in the server directory. I installed postgres for another project and created a new database called pet_names. I've never used knex before but I tried running the knex migrate:up command and my terminal doesnt recognize the knex command-line tool. Maybe we can walk through it on my machine when we link up? We also should probably establish some environment vars especially for the postgres password, and use concurrently to consolidate the server activation and seeding process.

We should start a groupchat or something on WhatsApp if that seems like something you all would be interested in?

murjax commented 1 year ago

What I noticed is that in the server/index.js directory, the getNames query in queries.js is being called via the localhost:3000/names endpoint. I guess that adding a url param is one way to go about it, but the one I know works is sending the state in the request.body. this also makes it easier to test via Postman or Insomnia.

I haven't used Insomnia so I can't speak on that one. Postman can differentiate between query and body params easily though.

Query param added from "params" tab: Screenshot from 2023-04-30 19-09-39

Body added from "body" tab: Screenshot from 2023-04-30 19-10-13

I typically see query params used for resource scoping like this, and it's the pattern I follow. That said, there's no specific HTTP standard for this so I'm open changing it. I think it's worth all of us understanding the difference between them though so I'll bring it up at the meetup!

I will come to the coffee shop this Tuesday. @murjax, I was wondering if you could edit the README in the server directory. I installed postgres for another project and created a new database called pet_names. I've never used knex before but I tried running the knex migrate:up command and my terminal doesnt recognize the knex command-line tool. Maybe we can walk through it on my machine when we link up?

I installed it globally to get it added to the path: npm install knex -g Let me know if it doesn't work for any reason. I'll update the README. Good callout!

We also should probably establish some environment vars especially for the postgres password, and use concurrently to consolidate the server activation and seeding process.

Agreed. Production will have different credentials than dev. I'll look into solutions for this (I'm not familiar offhand how to do env var reading in node).