Skip to content

Commit 07eeb86

Browse files
committed
fix: fetching and parsing remote urls
1 parent 0d7bcc4 commit 07eeb86

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ module.exports = (options = {}) => tree => {
4444
.then(responseAssign)
4545
.then(() => {
4646
if (isUrl(url)) {
47-
return ofetch(url, options.ofetch)
47+
return ofetch(url, options.ofetch).then(response => ({
48+
body: response
49+
}))
4850
}
4951

5052
const response = {
@@ -67,7 +69,9 @@ module.exports = (options = {}) => tree => {
6769
merge(
6870
options.expressions,
6971
{
70-
locals: {response: JSON.parse(body)}
72+
locals: {
73+
response: typeof body === 'object' ? body : JSON.parse(body)
74+
}
7175
}
7276
))
7377
)

0 commit comments

Comments
 (0)