deploy to gcloud
This commit is contained in:
1 parent
e4e364ae2a
commit
4b7252c15f
12 files changed
+190
-121
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { Plugin } from '@nuxt/types'
|
||||
|
||||
const plugin: Plugin = ({ $axios, error }) => {
|
||||
if (typeof location !== 'undefined') {
|
||||
$axios.defaults.baseURL = location.origin
|
||||
}
|
||||
|
||||
$axios.interceptors.response.use(
|
||||
(r) => {
|
||||
if (r.data?.error) {
|
||||
error({
|
||||
statusCode: r.status,
|
||||
message: r.data.error,
|
||||
})
|
||||
throw new Error(r.data.error)
|
||||
}
|
||||
|
||||
return r
|
||||
},
|
||||
(err) => {
|
||||
error({
|
||||
statusCode: err.response.status,
|
||||
message: err.toJSON(),
|
||||
})
|
||||
|
||||
return Promise.reject(err)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default plugin
|
||||
Reference in new issue
Block a user