helpful-functions
Advanced tools
Comparing version 1.0.6 to 1.0.7
{ | ||
"name": "helpful-functions", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/", |
@@ -31,3 +31,50 @@ import cloneDeep from "lodash.clonedeep"; | ||
}; | ||
/** | ||
* Getter function to fetch json data from given path | ||
* | ||
* @param src the filepath or url path to the json data | ||
* @returns json response | ||
* | ||
*/ | ||
export const get = async (src: string, config: object = {}): Promise<JSON> => { | ||
const response = await fetch(src, config); | ||
const json = await response.json(); | ||
return json; | ||
}; | ||
/** | ||
* | ||
* @param src the url path or file path | ||
* @param payload the body request data wanting to be sent | ||
* @param config any other settings that can be added to the fetch js api | ||
* @returns json response | ||
*/ | ||
export const post = async ( | ||
src: string, | ||
payload: object, | ||
config: object = {} | ||
): Promise<JSON> => { | ||
const response = await fetch(src, { | ||
...config, | ||
method: "POST", | ||
body: JSON.stringify(payload), | ||
}); | ||
const json = await response.json(); | ||
return json; | ||
}; | ||
/** | ||
* This prints the string with the colors in the console | ||
* | ||
* @param array of colors | ||
* | ||
*/ | ||
export const logColors = (arrayOfColors: string[]): void => { | ||
arrayOfColors.forEach((color) => { | ||
console.log(`%c ${color}`, `color: ${color}`); | ||
}); | ||
}; | ||
/** | ||
* 10 good colors that work together | ||
@@ -48,16 +95,4 @@ */ | ||
/** | ||
* This prints the string with the colors in the console | ||
* | ||
* @param array of colors | ||
* | ||
*/ | ||
export const logColors = (arrayOfColors: string[]): void => { | ||
arrayOfColors.forEach((color) => { | ||
console.log(`%c ${color}`, `color: ${color}`); | ||
}); | ||
}; | ||
// const main = () => { | ||
// }; | ||
// main(); |
14046
255