Skip to content

Commit

Permalink
fix(ui): Using fetchSync twice in plugin results in error (fixes #242)
Browse files Browse the repository at this point in the history
  • Loading branch information
flawiddsouza committed Sep 13, 2024
1 parent 7dabab4 commit fa1ebb8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/ui/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,12 @@ function addFetchSyncToVM(vm: QuickJSAsyncContext) {
vm.setProp(responseObject, 'statusText', responseStatusText)

const responseHeaders = vm.evalCode(`
const escapedText = JSON.stringify(${JSON.stringify(response.headers)})
const headersArray = JSON.parse(escapedText)
const headers = new Headers(headersArray)
headers
{
const escapedText = JSON.stringify(${JSON.stringify(response.headers)})
const headersArray = JSON.parse(escapedText)
const headers = new Headers(headersArray)
headers
}
`)

vm.setProp(responseObject, 'headers', vm.unwrapResult(responseHeaders))
Expand Down

0 comments on commit fa1ebb8

Please sign in to comment.