rails / request.js

MIT License
389 stars 28 forks source link

Make `query` to accept a FormData and URLSearchParams #27

Closed marcelolx closed 3 years ago

marcelolx commented 3 years ago

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: https://github.com/rails/request.js/pull/28