mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
docs: improve GET request example clarity in documentation. (#10836)
* Improve GET request example clarity in documentation. Updated example GET request to use params for clarity. * Fix indentation in GET request example --------- Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -495,8 +495,16 @@ axios
|
||||
// Want to use async/await? Add the `async` keyword to your outer function/method.
|
||||
async function getUser() {
|
||||
try {
|
||||
const response = await axios.get('/user?ID=12345');
|
||||
console.log(response);
|
||||
// Example: GET request with query parameters
|
||||
const response = await axios.get('/user', {
|
||||
params: {
|
||||
ID: 12345
|
||||
}
|
||||
});
|
||||
|
||||
// Using the `params` option improves readability and automatically formats query strings
|
||||
|
||||
console.log(response);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user