Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const baseURI = '/imonitor/api/v1/';
- async function getCategoriesList() {
- const res = await fetch(`${baseURI}category/list`);
- return res.json()
- }
- async function getLocationsList() {
- const res = await fetch(`${baseURI}location/list`);
- return res.json();
- }
- async function getRegionsList() {
- const res = await fetch(`${baseURI}location/region/list`);
- return res.json();
- }
- async function getCitiesList() {
- const res = await fetch(`${baseURI}location/city/list`);
- return res.json();
- }
- async function getPostList() {
- const res = await fetch(`${baseURI}post/list`);
- return res.json();
- }
- async function getPostById(id) {
- const res = await fetch(`${baseURI}post/${id}/`);
- return res.json();
- }
- async function postPost(data) {
- const res = await fetch(`${baseURI}post/`, {
- method: 'POST',
- mode: 'cors',
- cache: 'no-cache',
- credentials: 'same-origin',
- headers: {'Content-Type': 'application/json'},
- redirect: 'follow',
- referrerPolicy: 'no-referrer',
- body: JSON.stringify(data)
- });
- return res.json();
- }
- function removeOptions(selectElement) {
- let i, L = selectElement.options.length - 1;
- for(i = L; i >= 0; i--) {
- selectElement.remove(i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement