Sending HTTP requests
config
All methost accept config object to configure request
Value | Type |
---|---|
endpoint | String |
params | Object |
paramsSerializer | function |
method | String |
baseURL | String |
headers | Object |
body | Object |
prepareBody | function |
cache | String |
credentials | String |
mode | String |
endpoint
Requesr endoint Url. Note that this url will be concated with baseURL
caution
endpoint
should not contain trailing slashes
params
Object that will be converted to query string
paramsSerializer
Is function that will convert params
Object to query string. You can setup default paramsSerializer while creating an instance. And use specific paramsSerializer for particular request.
method
baseURL
With this option you can override instance baseURL
headers
With this option you can override instance headers
body
Is the data to be sent as the request body. In general it will be automatically converted to String or FormData so you should not be worry about that.
note
body
will be skipped for GET request
signal
isMultipartFormData
With this option you can override instance isMultipartFormData
prepareBody
function that will convert data to String or FormData before sending HHTP request. In general this functoin is already implemented and u can use it only in really specific cases
cache
credentials
mode
request
General method to sent whatever HTTP request. Returns promise
get
Method to sent GET HTTP request. Returns promise
delete
Method to sent DELETE HTTP request. Returns promise
options
Method to sent OPTIONS HTTP request. Returns promise
post
Method to sent POST HTTP request. Returns promise
put
Method to sent PUT HTTP request. Returns promise
patch
Method to sent PATCH HTTP request. Returns promise
dynamic url
You can use dynamic url using path-to-regexp syntax. Dynamic urls will be compiled with params.