trae, the fetch library
the fetch library
by Huemul
const result = document.getElementById('result');
const url = 'https://jsonplaceholder.typicode.com/posts/1';
function success(res) {
res.data.title = res.data.title.slice(0, 8);
res.data.body = res.data.body.slice(0, 20) + '...';
return Promise.resolve(res);
}
trae.after(success);
trae.get(url)
.then((res) => {
let html = '\n// request final reponse\n';
html += JSON.stringify(res, null, '\t');
result.innerHTML += html;
});