You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+45Lines changed: 45 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,15 @@ async myMethod () {
71
71
}
72
72
```
73
73
74
+
### responseKind
75
+
76
+
You can provide this option to specify which kind of response will be accepted. Default is `html`.
77
+
78
+
Options are `html`, `turbo-stream`, `json`.
79
+
80
+
### contentType
81
+
82
+
When provided this value will be sent in the `Content-Type` header. When not provided Request.JS will send nothing when the `body` of the request is `null` or an instance of `FormData`, when the `body` is an instance of a `File` then the type of the file will be sent and `application/json` will be sent if none of the prior conditions matches.
74
83
75
84
#### Turbo Streams
76
85
@@ -81,6 +90,8 @@ import { Turbo } from "@hotwired/turbo-rails"
81
90
window.Turbo= Turbo
82
91
```
83
92
93
+
Since [v7.0.0-beta.6](https://github.com/hotwired/turbo/releases/tag/v7.0.0-beta.6) Turbo sets `window.Turbo` automatically.
94
+
84
95
#### Request Interceptor
85
96
86
97
To authenticate fetch requests (eg. with Bearer token) you can use request interceptor. It allows pausing request invocation for fetching token and then adding it to headers:
Returns true if the response has a `401` status code.
126
+
127
+
### authenticationURL
128
+
129
+
Returns the value contained in the `WWW-Authenticate` header.
130
+
131
+
### contentType
132
+
133
+
Returns the response content-type.
134
+
135
+
### html
136
+
137
+
Returns the html body, if the content type of the response isn't `html` then will be returned a rejected promise.
138
+
139
+
### json
140
+
141
+
Returns the json body, if the content type of the response isn't `json` then will be returned a rejected promise.
142
+
143
+
### headers
144
+
145
+
Returns the response headers.
146
+
102
147
# Known Issues
103
148
104
149
`FetchRequest` sets a `"X-Requested-With": "XmlHttpRequest"` header. If you have not upgraded to Turbo and still use `Turbolinks` in your Gemfile, this means
0 commit comments