@b360/get-api-key 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +43 -0
  2. package/package.json +13 -0
package/index.js ADDED
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ var config = require('@b360/config');
4
+ // var DEFAULT_KEYS = config();
5
+
6
+ // var API_URL = DEFAULT_KEYS['api_url'];
7
+ // var api_key = DEFAULT_KEYS['api_key'];
8
+
9
+ // sample
10
+ exports.GetApiKey = async (username, key="cloudVersion", appType, appCategory, appApiUrl = '', appApiKey = '', appPluginUrl = '') => {
11
+ var DEFAULT_KEYS = config(appType, appCategory, appApiUrl, appApiKey, appPluginUrl);
12
+ var myHeaders = new Headers();
13
+ myHeaders.append("REFERER", DEFAULT_KEYS['api_url']);
14
+ // myHeaders.append("REFERER", "http://localhost/websites/b360/api/");
15
+ var formdata = new FormData();
16
+ formdata.append("username",username);
17
+ formdata.append("key",key);
18
+
19
+ var requestOptions = {
20
+ method: 'POST',
21
+ headers: myHeaders,
22
+ body: formdata,
23
+ redirect: 'follow'
24
+ };
25
+
26
+ return fetch(DEFAULT_KEYS['api_url']+'admin/get_options', requestOptions)
27
+ .then(response => response.text())
28
+ .then(result => {
29
+ result = JSON.parse(result);
30
+ console.log(result.status);
31
+ console.log(result.message);
32
+ if(result.status){
33
+ result = result.message;
34
+ }else{
35
+ result = [];
36
+ }
37
+ return result;
38
+ })
39
+ .catch((error) => {
40
+ console.log('error', error)
41
+ return error;
42
+ });
43
+ }
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@b360/get-api-key",
3
+ "version": "1.0.0",
4
+ "description": "sample description",
5
+ "main": "index.js",
6
+ "author": "uday veduruvada",
7
+ "license": "ISC",
8
+ "devDependencies": {},
9
+ "dependencies": {},
10
+ "publishConfig": {
11
+ "access": "public"
12
+ }
13
+ }