File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -193,3 +193,47 @@ export default class Model extends BaseModel {
193193 }
194194}
195195```
196+
197+ ## Configuring FormData
198+
199+ See the [ API reference] ( /api/model-options#formdata ) and [ object-to-formdata] ( https://github.com/therealparmesh/object-to-formdata#usage )
200+
201+ When uploading files, the data of our request will be automatically converted to ` FormData ` using ` object-to-formdata ` .
202+
203+ If needed, we can easily configure the options by overriding the ` formData ` method.
204+
205+ We can globally configure this in the [ Base Model] ( /configuration#creating-a-base-model ) :
206+
207+ ``` js{}[~/models/Model.js]
208+ import { Model as BaseModel } from 'vue-api-query'
209+
210+ export default class Model extends BaseModel {
211+
212+ // Define a base url for a REST API
213+ baseURL() {
214+ return 'http://my-api.com'
215+ }
216+
217+ // Implement a default request method
218+ request(config) {
219+ return this.$http.request(config)
220+ }
221+
222+ // Override default query parameter names
223+ parameterNames() {
224+ const defaultParams = super.parameterNames()
225+ const customParams = {
226+ include: 'include_custom'
227+ }
228+
229+ return { ...defaultParams, ...customParams }
230+ }
231+
232+ // Configure object-to-formadata
233+ formData() {
234+ return {
235+ indices: true
236+ }
237+ }
238+ }
239+ ```
You can’t perform that action at this time.
0 commit comments