forlooptanzania / ride-my-way

Car pooling app (of developers) by developers for developers in Tanzania
22 stars 6 forks source link

Weekly Support, 29th May 2019 #36

Open joshuamabina opened 5 years ago

joshuamabina commented 5 years ago

Hi all!

Kindly drop in any question on the topic: Building Web Services using Node.js.

We will be joining a Q & A session with 17:00 HRS EAT. Please attend without fail to be able to unlock and unblock your world-class developer potential.

Join Zoom Meeting using https://andela.zoom.us/j/668566256

landrykapela commented 5 years ago

Hi! Those with issues on the HTTP verbs this link could be useful https://www.restapitutorial.com/lessons/httpmethods.html

veemish commented 5 years ago

Get is used to request data from a specified resource. while Put is used to send data to a server to create/update a resource. also Post is used to send data to a server to create/update a resource.

ghost commented 5 years ago

What is the difference between a PATCH method and a PUT method?

A PATCH method can be used to update existing information partially in a server , while a PUT method can be used to update it entirely.

For example: If you have a JSON object with various attributes such as name, age, phone number, and address, you can use PATCH to update just one of them. But if you want to makes changes to all attributes, then you use the PUT method for that.

lupyana commented 5 years ago

API response

What

HTTP status codes are standard response codes communicated by the server to the client to tell about a request. When communicating with the api, we expect to get response in a certain format. Among other parts of the response, one key part is a status code.

A status code is a number that tells us if request has been successfully completed.

You don’t need to know every HTTP status code, but there are important HTTP status codes you must be familiar with

focus more on 2xx and 4xx.

A detailed reference can be found here see Docs and here

Why

There are many reasons to why they are important, here is a few from the top of my head

noelnoja commented 5 years ago

Screenshot (1054) Screenshot (1055)

need help on how I can access the first object in Ride array

lupyana commented 5 years ago

Screenshot (1054) Screenshot (1055)

need help on how I can access the first object in Ride array

I can see in your postman the address is localhost:3000/api/api/....... you wrote api twice, is that correct?

noelnoja commented 5 years ago

Oops my bad @lupyana, I've tried to change it but still getting the same response

lupyana commented 5 years ago

Oops my bad @lupyana, I've tried to change it but still getting the same response

Check on how you are assigning the id from request parameter, Just before you return the response. Is that correct?

landrykapela commented 5 years ago

Did you declare the _id variable?

lupyana commented 5 years ago

Oops my bad @lupyana, I've tried to change it but still getting the same response

Check on how you are assigning the id from request parameter, Just before you return the response. Is that correct?

Is that the new syntax of assigning variables?

elineka commented 5 years ago

Can i use get, post, put method in one API file ? or do i need different file for every API method?

1)It is okay if it works but not recommended because of its difficult in maintenance Imagine passing through many lines of code, find one line and trying to make some changes its difficult. So you could make the code more readable by arranging properly your APIs like implementing it in different file. 2)By using separate file allow for clear and clean separation of different method allowing easier reading and updating document.

See #38

noelnoja commented 5 years ago

it's working now @lupyana @landrykapela thank you guys