Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weekly Support, 29th May 2019 #36

Open
joshuamabina opened this issue May 29, 2019 · 12 comments
Open

Weekly Support, 29th May 2019 #36

joshuamabina opened this issue May 29, 2019 · 12 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@joshuamabina
Copy link
Contributor

joshuamabina commented May 29, 2019

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

@joshuamabina joshuamabina added help wanted Extra attention is needed question Further information is requested labels May 29, 2019
@landrykapela
Copy link

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

@veemish
Copy link

veemish commented May 29, 2019

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
Copy link

ghost commented May 29, 2019

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
Copy link

lupyana commented May 29, 2019

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

  • 1xx Status Codes: Information Request
  • 2xx Status Codes: Success
  • 3xx Status Codes: Redirection
  • 4xx Status Codes: Client Error
  • 5xx Status Codes: Server Error

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

  • Ease in communication, It is easy for a client to know the status of the request

  • Ease in debugging. Before you start pulling your hair why it doesn't work, first check the code, it will help you narrow down on what went wrong.

@xnoja
Copy link

xnoja commented May 30, 2019

Screenshot (1054)
Screenshot (1055)

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

@lupyana
Copy link

lupyana commented May 30, 2019

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?

@forlooptanzania forlooptanzania deleted a comment from veemish May 30, 2019
@xnoja
Copy link

xnoja commented May 30, 2019

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

@lupyana
Copy link

lupyana commented May 30, 2019

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
Copy link

Did you declare the _id variable?

@lupyana
Copy link

lupyana commented May 30, 2019

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
Copy link

elineka commented Jun 1, 2019

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

@xnoja
Copy link

xnoja commented Jun 1, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants