mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +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.
|
// Want to use async/await? Add the `async` keyword to your outer function/method.
|
||||||
async function getUser() {
|
async function getUser() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('/user?ID=12345');
|
// Example: GET request with query parameters
|
||||||
console.log(response);
|
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) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user