Validate url in fetch, rework some hints
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/lib",
|
||||
"version": "0.4.1",
|
||||
"version": "0.4.2",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of utilities.",
|
||||
|
||||
@@ -1291,6 +1291,9 @@ type FetchOpts = {
|
||||
* @returns Promise of parsed JSON response
|
||||
*/
|
||||
export const fetchJson = async (url: string, opts: FetchOpts = {}) => {
|
||||
// Make sure the url is valid, this will throw if not
|
||||
url = String(new URL(url))
|
||||
|
||||
if (!opts.headers) {
|
||||
opts.headers = {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user