Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools HTTP Basics GET and POST Requests in a Browser Using Forms for GET Requests

still don't understand why passing data along with GET request

the teacher said in the video "remember that passing data along with GET request means appending that data to the URI in query string format". I still don't get it why we want to pass data with GET? isn't GET supposed to be used as a way of retrieving data?

4 Answers

Just remember that if you want to retrieve data without modifying the database or whatever storage you are using, then get is the best option, if you intend to modify data in the database it is best to use the post. Moreover, there are times that even if you only need to retrieve data without modifying your data store it is best to use post since post hid the data that you are requesting from being seen. everything happens under the hood.

Abdullah Habib
PLUS
Abdullah Habib
Courses Plus Student 14,261 Points

The name is confusing, but to remove this misunderstanding think of it in term of how things works, the computer (browser) need to request data from the server on the internet. So i can send anything along with this request (query string in case of GET).

Continue learning and things later on will gets more clearer. especially in REST subject.

Shawn Lindsey
Shawn Lindsey
20,952 Points

I'm still new to this, so hopefully the below isn't inaccurate, but conceptualizing it this way helped me resolve this same confusion:

Think of sending data with your GET request as supplying additional information in order to add greater specificity to what the response is going to give you. The data isn't being used to add anything to the response data, it's just to help make sure you're getting exactly the kind of data you want. It happens to be that the method for providing that data with GET requests is using query strings.

Another way to think of it would be ordering something off of amazon. You don't just send a request for stuff. You send a request for specific products, and that information about what exact products you want is itself data. In other words, sometimes to GET something, you need to provide something to make sure you get the right thing.

POST is more secure (since it puts this data you're supplying into the body rather than in the URL) and has no size limit (URL's can only be so long). An implication of this, as Salim mentioned above, is that POST can be used even when you're not modifying something, if using the body is more appropriate to the request.

Nick Huemmer
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Nick Huemmer
Front End Web Development Techdegree Graduate 26,840 Points

Could it be thought of like this?

GET = getting information from the host, pulling information off (whether through a search or other request) but not changing anything.

POST = putting something on the host, changing or adding information.

Perhaps this is overly simplistic, but I'm simple-minded.