Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

vanilla javascript axios

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

const createUser = (user) => {
 axios.post('https://reqres.in/api/users', user)
 .then(response => {
 const addedUser = response.data;
 console.log(`POST: user is added`, addedUser);
// append to DOM
 appendToDOM([addedUser]);
 })
 .catch(error => console.error(error));
};
Source by javascript.plainenglish.io #
 
PREVIOUS NEXT
Tagged: #vanilla #javascript #axios
ADD COMMENT
Topic
Name
7+3 =