Comparing version 0.0.2 to 0.0.3
@@ -37,4 +37,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import axios from "axios"; | ||
var getify = function (url) { return __awaiter(void 0, void 0, void 0, function () { | ||
var urlAndParamsRaw, urlBase, paramsRaw, params, i, keyValue; | ||
var urlAndParamsRaw, urlBase, paramsRaw, urlVars, i, keyValue, reqUrl, paramsKeys, paramsValues, i; | ||
return __generator(this, function (_a) { | ||
@@ -44,8 +45,25 @@ urlAndParamsRaw = url.split("?"); | ||
paramsRaw = urlAndParamsRaw[1].split("&"); | ||
params = {}; | ||
urlVars = {}; | ||
for (i = 0; i < paramsRaw.length; i++) { | ||
keyValue = paramsRaw[i].split("="); | ||
params[keyValue[0]] = keyValue[1]; | ||
if (keyValue[0] == "params") { | ||
urlVars[keyValue[0]] = JSON.parse(keyValue[1]); | ||
} | ||
else { | ||
urlVars[keyValue[0]] = keyValue[1]; | ||
} | ||
} | ||
console.log(urlBase, params); | ||
reqUrl = "".concat(urlBase, "?"); | ||
paramsKeys = Object.keys(urlVars["params"]); | ||
paramsValues = Object.values(urlVars["params"]); | ||
console.log(paramsKeys); | ||
for (i = 0; i < paramsKeys.length; i++) { | ||
if (i == paramsKeys.length - 1) { | ||
reqUrl += "".concat(paramsKeys[i], "=").concat(paramsValues[i]); | ||
} | ||
else { | ||
reqUrl += "".concat(paramsKeys[i], "=").concat(paramsValues[i], "&"); | ||
} | ||
} | ||
axios.get(reqUrl); | ||
return [2 /*return*/, "getify"]; | ||
@@ -52,0 +70,0 @@ }); |
{ | ||
"name": "getfy", | ||
"version": "0.0.2", | ||
"license":"MIT", | ||
"version": "0.0.3", | ||
"license": "MIT", | ||
"packageManager": "yarn@4.3.1", | ||
@@ -11,3 +11,3 @@ "main": "build/index.js", | ||
}, | ||
"scripts":{ | ||
"scripts": { | ||
"build": "tsc", | ||
@@ -14,0 +14,0 @@ "dev": "build && node test.js" |
@@ -0,1 +1,3 @@ | ||
import axios from "axios" | ||
const getify = async (url:string)=>{ | ||
@@ -5,8 +7,23 @@ const urlAndParamsRaw = url.split("?") | ||
const paramsRaw = urlAndParamsRaw[1].split("&") | ||
const params = {} | ||
let urlVars = {} | ||
for(let i =0;i < paramsRaw.length; i++){ | ||
const keyValue = paramsRaw[i].split("=") | ||
params[keyValue[0]] = keyValue[1] | ||
if(keyValue[0] == "params"){ | ||
urlVars[keyValue[0]] = JSON.parse(keyValue[1]) | ||
}else{ | ||
urlVars[keyValue[0]] = keyValue[1] | ||
} | ||
} | ||
console.log(urlBase,params) | ||
let reqUrl = `${urlBase}?`; | ||
const paramsKeys = Object.keys(urlVars["params"]) | ||
const paramsValues = Object.values(urlVars["params"]) | ||
console.log(paramsKeys) | ||
for(let i=0;i<paramsKeys.length;i++){ | ||
if(i == paramsKeys.length -1){ | ||
reqUrl += `${paramsKeys[i]}=${paramsValues[i]}` | ||
}else{ | ||
reqUrl += `${paramsKeys[i]}=${paramsValues[i]}&` | ||
} | ||
} | ||
axios.get(reqUrl) | ||
return "getify" | ||
@@ -13,0 +30,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7427
11
121