helpful-functions
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -24,3 +24,3 @@ /** | ||
*/ | ||
export declare const get: (src: string, config?: object) => Promise<JSON>; | ||
export declare const get: (src: string, config?: object | undefined) => Promise<JSON>; | ||
/** | ||
@@ -35,3 +35,3 @@ * Creates Post request and returns the response | ||
*/ | ||
export declare const post: (src: string, payload: object, config?: object) => Promise<JSON>; | ||
export declare const post: (src: string, payload: object, config?: object | undefined) => Promise<JSON>; | ||
/** | ||
@@ -38,0 +38,0 @@ * This prints the string with the colors in the console |
@@ -8,2 +8,3 @@ "use strict"; | ||
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep")); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
/** | ||
@@ -34,4 +35,4 @@ * Function that returns if the array is empty or not | ||
*/ | ||
const get = async (src, config = {}) => { | ||
const response = await fetch(src, config); | ||
const get = async (src, config) => { | ||
const response = await node_fetch_1.default(src, config); | ||
const json = await response.json(); | ||
@@ -50,6 +51,10 @@ return json; | ||
*/ | ||
const post = async (src, payload, config = {}) => { | ||
const response = await fetch(src, { | ||
const post = async (src, payload, config) => { | ||
const response = await node_fetch_1.default(src, { | ||
...config, | ||
method: "POST", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(payload), | ||
@@ -88,5 +93,5 @@ }); | ||
]; | ||
// const main = () => { | ||
// const main = async () => { | ||
// }; | ||
// main(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "helpful-functions", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "", | ||
@@ -25,2 +25,3 @@ "main": "dist/", | ||
"@types/lodash.clonedeep": "^4.5.6", | ||
"@types/node-fetch": "^2.5.10", | ||
"ts-node": "^10.0.0", | ||
@@ -30,4 +31,5 @@ "typescript": "^4.3.4" | ||
"dependencies": { | ||
"lodash.clonedeep": "^4.5.0" | ||
"lodash.clonedeep": "^4.5.0", | ||
"node-fetch": "^2.6.1" | ||
} | ||
} |
import cloneDeep from "lodash.clonedeep"; | ||
import fetch from "node-fetch"; | ||
@@ -28,3 +29,3 @@ /** | ||
*/ | ||
export const get = async (src: string, config: object = {}): Promise<JSON> => { | ||
export const get = async (src: string, config?: object): Promise<JSON> => { | ||
const response = await fetch(src, config); | ||
@@ -47,3 +48,3 @@ const json = await response.json(); | ||
payload: object, | ||
config: object = {} | ||
config?: object | ||
): Promise<JSON> => { | ||
@@ -53,2 +54,6 @@ const response = await fetch(src, { | ||
method: "POST", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(payload), | ||
@@ -88,4 +93,4 @@ }); | ||
// const main = () => { | ||
// const main = async () => { | ||
// }; | ||
// main(); |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
15735
287
0
2
4
+ Addednode-fetch@^2.6.1
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)