Open xgqfrms opened 6 years ago
PUT
vs
PATCH ?OPTIONS ?
vs
update partlyhttps://stackoverflow.com/questions/24241893/rest-api-patch-or-put
http://restcookbook.com/HTTP%20Methods/patch/
https://restful-api-design.readthedocs.io/en/latest/methods.html
https://philsturgeon.uk/api/2016/05/03/put-vs-patch-vs-json-patch/
"use strict";
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
*
* @description POST & Fetch
*
* @augments
* @example
*
*/
const fetchPOSTJSON = (url = ``, obj = {}) => {
return fetch(url,
{
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
body: JSON.stringify(obj),
}).then(res => res.json())
.then(
(json) => {
console.log(`POST configs OK!`);
return json;
}
).catch(err => console.log(`fetch error & POST configs Error!`, err));
};
// async / await
async function getPOSTDatas(url = ``, obj = {}) {
try {
return await fetchJSON(url, obj);
} catch (err) {
console.error("getDatas error:\n", err);
}
}
const fetchPUTJSON = (url = ``, obj = {}) => {
return fetch(url,
{
method: "PUT",
mode: "cors",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
body: JSON.stringify(obj),
}).then(res => res.json())
.then(
(json) => {
console.log(`PUT configs OK!`);
return json;
}
).catch(err => console.log(`fetch error & PUT configs Error!`, err));
};
// Error
// fetchPUTJSON(`http://10.1.5.202:7777/componentConfig?id=fb-hc`, obj);
// OK & PS: id can not be changed!
// fetchPUTJSON(`http://10.1.5.202:7777/componentConfig/fb-hc`, obj);
const fetchDeleteJSON = (url = ``) => {
return fetch(url,
{
method: "DELETE",
mode: "cors",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
}).then(res => res.json())
.then(
(json) => {
console.log(`DELETE configs OK!`);
return json;
}
).catch(err => console.log(`fetch error & DELETE configs Error!`, err));
};
// fetchDeleteJSON(`http://10.1.5.202:7777/componentConfig/fb-hc`);
https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop
"use strict";
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
*
* @description AuoScroll
* @augments
* @example
*
*/
const AuoScroll = (datas = [], debug = false) => {
let result = ``;
// do something...
return result;
};
let tableBox = document.querySelector(`[class="infos-table-box"]`),
table = document.querySelector(`[data-box="progress"]`);
tableBox.scrollTop = table.clientHeight;
// tableBox.scrollTop = table.offsetHeight;
// window.scrollTo(x, y);
// table.scrollTo(0, 10000);
// tableBox.scrollTop = 100000;
// table.clientHeight;
// table.offsetHeight;
// export default AuoScroll;
// export {
// AuoScroll,
// };
https://developer.mozilla.org/en-US/docs/Web/API/History_API
https://html5demos.com/history/
HTML5 History API
Fetch & POST & JSON Server
JSON Server