Helpers available on $http instance.
::alert{type="info"}
Helpers available on $http
instance.
::
- arguments:
(baseURL)
Globally set a base URL to all subsequent requests
// Set baseURL (both client and server)
this.$http.setBaseURL('http://api.example.com')
// Change URL only for client
if (process.client) {
this.$http.setBaseURL('http://api.example.com')
}
// Change URL only for server
if (process.server) {
this.$http.setBaseURL('http://api.example.com')
}
Get the value of the base URL
// Get baseURL value
this.$http.getBaseURL()
- arguments:
(name, value)
Globally set a header to all subsequent requests
Example:
// Add header `Content-Type: application/json`
this.$http.setHeader('Content-Type', 'application/json')
See here for usage.
- arguments:
(token, type)
Globally set a Authorization
header for all subsequent requests.
// Adds header: `Authorization: Bearer 123` to all requests
this.$http.setToken('123', 'Bearer')
See here for usage.
- arguments:
(kyOptions)
Create a new KY instance based on defaults, see create new instance based on defaults for usage.