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ì

Promise.all là gì?

Promise.all là gì? Hiểu và sử dụng promise all trong những trường hợp nào trong vòng 1 phút.

Sử dụng Promise.all với fetch

Sử dụng Promise.all hiệu quả sẽ làm cho hiệu suất của code chúng ta tăng lên đáng kể. Và mã sau đây giúp các bạn có thể get được nhiều data mà không ảnh hưởng tới performance.

axios post 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...

using javascript callback style error handling