Skip to content

Commit

Permalink
Default to json content type header
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-lippert committed Jan 13, 2024
1 parent f36351a commit f68e746
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export class State {
const init = callbacks[i].init || meta?.init || {}
init.headers = callbacks[i].headers || meta?.headers || init.headers || {}
init.method = callbacks[i].method || meta?.method || init.method || init.body ? 'POST' : 'GET'
if (!init.body && ['POST', 'PUT', 'PATCH'].includes(init.method)) {
if (!init.body && ['POST', 'PUT', 'PATCH'].includes(init.method))
init.body = JSON.stringify(callbacks[i].body || meta?.body || state.event)
if (!init.headers['content-type']) init.headers['content-type'] = 'application/json'
}
if (init.body && !init.headers['content-type'])
init.headers['content-type'] = 'application/json'
console.log({ url, init, state })
const data = await fetch(url, init)
// Escape special regex characters and replace x with \d to check if the callback status code matches an event (e.g. 2xx)
Expand Down

0 comments on commit f68e746

Please sign in to comment.