Closed adrienpoly closed 3 years ago
close #9
This PR adds shorthand functions to directly call one specific HTTP request verb.
5 new functions are available : get, post, put, patch, destroy
import {get, post, put, patch, destroy} from '@rails/request.js' async myMethod () { const response = await post('localhost:3000/my_endpoint', { body: { name: 'Request.JS' }})) if (response.ok) { const body = await response.text ... } }
destroy
delete is a javascript reserved word so for this shorthand function I used destroy
delete
Great @adrienpoly! Could you please add a section on the README about this functionality?
@marcelolx I added a small documentation part to the readme
Thanks @adrienpoly
close #9
This PR adds shorthand functions to directly call one specific HTTP request verb.
5 new functions are available : get, post, put, patch, destroy
Example
DELETE ->
destroy
delete
is a javascript reserved word so for this shorthand function I useddestroy