axios post await

axios,web_developer,http,api,promise,await

Axios là một HTTP client được viết dựa trên Promises được dùng để hỗ trợ cho việc xây dựng các ứng dụng API từ đơn giản đến phức tạp. Có thể sử axios để post, get, put, delete...

Tips: Tìm hiểu sâu về axios

Post request

const newPost = {
    userId: 1,
    title: 'A new post',
    body: 'This is the body of the new post'
}
const sendPostRequest = async () => {
    try {
        const resp = await axios.post('https://jsonplaceholder.typicode.com/posts', newPost);
        console.log(resp.data);
    } catch (err) {
        // Handle Error Here
        console.error(err);
    }
}
sendPostRequest();

Có thể bạn đã miss một số snippets code

Promise + gì

promise + gì

Detect when your site is visible to users

Detect when your site is visible to users

using Typescript callback style error handling

promise in javascript

promise in javascript

await axios get

await axios get