// GET Request
axios({
method: 'GET',
url: 'http://localhost:3000/posts/2',
}).then((response) => {
console.log(response);
});
// POST Request
axios({
method: 'POST',
url: 'http://localhost:3000/posts',
data: {
title: 'New Post Title',
author: 'Zhang San',
},
}).then((response) => {
console.log(response);
});
// PUT Request (Update)
axios({
method: 'PUT',
url: 'http://localhost:3000/posts/3',
data: {
title: 'Updated Title',
author: 'Li Si',
},
}).then((response) => {
console.log(response);
});
// DELETE Request
axios({
method: 'delete',
url: 'http://localhost:3000/posts/3',
}).then((response) => {
console.log(response);
});