Skip to content

Commit 0c6a469

Browse files
committed
add documentation
1 parent 6b92888 commit 0c6a469

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,26 @@ async myMethod () {
3535
}
3636
```
3737

38+
#### Shorthand methods
39+
40+
Alternatively, you can use a shorthand version for the main HTTP verbs, `get`, `post`, `put`, `patch` or `destroy`.
41+
42+
Example:
43+
44+
```js
45+
import { get, post, put, patch, destroy } from '@rails/request.js'
46+
47+
...
48+
49+
async myMethod () {
50+
const response = await post('localhost:3000/my_endpoint', { body: { name: 'Request.JS' }})
51+
if (response.ok) {
52+
...
53+
}
54+
}
55+
```
56+
57+
3858
#### Turbo Streams
3959

4060
Request.JS will automatically process Turbo Stream responses. Ensure that your Javascript sets the `window.Turbo` global variable:

0 commit comments

Comments
 (0)