biz9-remote
Version:
** Description
43 lines (42 loc) • 1.25 kB
JavaScript
/*
Copyright 2016 Certified CoderZ
Author: Brandon Poole Sr. (biz9framework@gmail.com)
License GNU General Public License v3.0
Description: BiZ9 Framework: Remote
*/
const {Scriptz}=require("biz9-scriptz");
const {Log}=require("biz9-utility");
class Remote_Field {
static APP_ID = 'app_id';
static POST = 'POST';
static GET = 'GET';
static DELETE = 'DELETE';
}
class Remote {
static get_url = (app_id,host,url,param) => {
if(!param){
param='';
}
var app_id_url="?"+Remote_Field.APP_ID+"="+app_id;
return host+"/"+url+app_id_url + param;
};
static post = async (url,obj) => {
const response = await fetch(url, {
method: Remote_Field.POST,
headers: {'Content-Type': 'application/json',},
body: JSON.stringify(obj)
});
const data_response = await response.json();
return [data_response.response,data_response.data];
};
static get = async (url) => {
const response = await fetch(url, {
method: Remote_Field.GET
});
const data_response = await response.json();
return [data_response.response,data_response.data];
};
}
module.exports = {
Remote,
};