Skip to content

Conversation

@marcelolx
Copy link
Collaborator

@marcelolx marcelolx commented Jul 28, 2021

Allows a user to send a FormData as query params. Request.js will parse the FormData to query params and append them to the URL in the same way it's done when an object is provided.

Example

import { get } from '@rails/request.js'
...
async myMethod () {
  const fakeForm = new FormData()
  fakeForm.append('name', 'Marcelo')
  get('/endpoint', { query: fakeForm }) // translates to /endpoint?name=Marcelo
}

Ref: #28

@marcelolx marcelolx force-pushed the get-with-body-as-form-data branch 4 times, most recently from 2b25ad3 to 82a0f84 Compare August 4, 2021 23:41
@marcelolx marcelolx changed the title Sends the body of idempotent requests as search params if it is a form data Make query to accept a FormData Aug 4, 2021
@marcelolx marcelolx marked this pull request as ready for review August 9, 2021 23:22
@marcelolx marcelolx force-pushed the get-with-body-as-form-data branch from 82a0f84 to ba15383 Compare August 10, 2021 11:23
@marcelolx marcelolx merged commit ebc432a into rails:main Aug 10, 2021
@marcelolx marcelolx deleted the get-with-body-as-form-data branch August 10, 2021 11:25
@marcelolx marcelolx changed the title Make query to accept a FormData Make query to accept a FormData and URLSearchParams Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants