Skip to content

Commit

Permalink
Default to post if there is a body
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-lippert committed Jan 13, 2024
1 parent be039f8 commit f36351a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class State {
const url = typeof callbacks[i] === 'string' || callbacks[i] instanceof String ? callbacks[i] : callbacks[i].url
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 || 'GET'
init.method = callbacks[i].method || meta?.method || init.method || init.body ? 'POST' : 'GET'
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'
Expand Down

0 comments on commit f36351a

Please sign in to comment.