Params & Body
new data.json
{
"users": [
{
"id": 1,
"firstname": "Alice",
"balance": 1000,
"credit_ID": 2
},
{
"id": 2,
"firstname": "Bob",
"balance": 500,
"credit_ID": 1
},
{
"id": 3,
"firstname": "Charlie",
"balance": 1500,
"credit_ID": 4
},
{
"id": 4,
"firstname": "David",
"balance": 2000,
"credit_ID": 3
}
],
"banks": [
{
"id": 1,
"owner": 1,
"sender": "Alice",
"receiver": 2,
"note": "For lunch",
"amount": 200,
"bank": "Bank A",
"type": "transfer"
},
{
"id": 2,
"owner": 2,
"sender": "Bob",
"receiver": 1,
"note": "Repayment",
"amount": 100,
"bank": "Bank B",
"type": "transfer"
},
{
"id": 3,
"owner": 3,
"sender": "Charlie",
"receiver": 4,
"note": "Gift",
"amount": 500,
"bank": "Bank C",
"type": "transfer"
},
{
"id": 4,
"owner": 1,
"sender": "Alice",
"receiver": 3,
"note": "For lunch",
"amount": 500,
"bank": "Bank A",
"type": "transfer"
},
{
"id": 5,
"owner": 1,
"sender": "Alice",
"receiver": null,
"note": "Dispose for expenses",
"amount": 300,
"bank": "Bank A",
"type": "dispose"
},
{
"id": 6,
"owner": 3,
"sender": null,
"receiver": "Charlie",
"note": "Withdraw for emergency",
"amount": 200,
"bank": "Bank C",
"type": "withdraw"
},
{
"id": 7,
"owner": 2,
"sender": null,
"receiver": "Bob",
"note": "Withdraw for rent",
"amount": 150,
"bank": "Bank B",
"type": "withdraw"
},
{
"id": 8,
"owner": 4,
"sender": null,
"receiver": "David",
"note": "Dispose for savings",
"amount": 1000,
"bank": "Bank C",
"type": "dispose"
},
{
"id": 9,
"owner": 4,
"sender": null,
"receiver": "David",
"note": "Withdraw for investment",
"amount": 700,
"bank": "Bank C",
"type": "withdraw"
},
{
"id": 10,
"owner": 2,
"sender": null,
"receiver": "Bob",
"note": "Dispose for utilities",
"amount": 80,
"bank": "Bank B",
"type": "dispose"
}
]
}
"Params" and "Body" are terminologies commonly used in the context of HTTP requests. They refer to different parts of the request that carry data to the server.
Params: Short for "parameters", they are typically used in the context of GET requests. Parameters are key-value pairs appended to the end of a URL after a question mark (?
). For example, in the URL https://example.com/search?q=hello
, q
is a parameter with the value hello
. Parameters are used to send small amounts of data to the server. In web development, frameworks, and libraries often provide convenient ways to parse and access these parameters.
-
Body: The body of an HTTP request is the main part of the request where you can send a larger amount of data to the server. It is commonly used in POST, PUT, and PATCH requests. The body is separated from the headers (which contain metadata about the request) by a blank line. The body can contain various types of data, such as JSON, XML, or plain text, depending on the content type specified in the headers of the request. In web development, the server-side code parses the body of the request to extract the necessary information sent by the client.