enigmatic 0.21.2 → 0.21.3
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.
- package/enigmatic.js +8 -1
- package/package.json +1 -1
package/enigmatic.js
CHANGED
|
@@ -121,7 +121,14 @@ w.state = new Proxy({}, {
|
|
|
121
121
|
|
|
122
122
|
w.get = async (url, options = {}, transform, key) => {
|
|
123
123
|
console.log(`fetching ${url}`)
|
|
124
|
-
let data
|
|
124
|
+
let data
|
|
125
|
+
if (url.startsWith('{') || url.startsWith('[')) {
|
|
126
|
+
data = JSON.parse(url)
|
|
127
|
+
} else {
|
|
128
|
+
let f = await fetch(url, options)
|
|
129
|
+
if (!f.ok) throw Error(`Could not fetch ${url}`)
|
|
130
|
+
data = await f.json()
|
|
131
|
+
}
|
|
125
132
|
if (transform) {
|
|
126
133
|
console.log('transforming ' + data)
|
|
127
134
|
data = transform(data)
|