JSFiddle - React, Tailwind, and code Playground
by eget teteete
HTML
<script src="ttps://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
JavaScript
const axios = require('axios');
/* fetch('https://api.novaposhta.ua/v2.0/json/', {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: {
"modelName": "Common",
"calledMethod": "getCargoTypes",
"methodProperties": {},
"apiKey": "966fe06277052a3879342cc5c651f44c"
}
})
.then(res => res.json())
.then(res => console.log(res.data))
*/
try {
axios.get('https://jsonplaceholder.typicode.com/posts/1')
.then(function(response) {
// handle success
console.log(response);
})
.catch(function(error) {
// handle error
console.log(error);
})
.then(function() {
// always executed
});
} catch (e) {
console.log(e)
}
fetch('https://api.novaposhta.ua/v2.0/json/', {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"modelName": "Common",
"calledMethod": "getCargoTypes",
"methodProperties": {},
"apiKey": "966fe06277052a3879342cc5c651f44c"
})
}).then(res => res.json())
.then(res => console.log(res));
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then((response) => response.json())
.then((json) => console.log(json))