Mercurial > gemma
annotate client/src/lib/http.js @ 5082:c4ebb6ccc588 time-sliding
client: start a request for the last changed time on time slider
* initiate a refresh layers request when the time for the
finished request differs from the selected time on time slider
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Wed, 18 Mar 2020 14:11:44 +0100 |
parents | 5555b77b8c4e |
children |
rev | line source |
---|---|
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1361
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
2 * without warranty, see README.md and license for details. |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1272
diff
changeset
|
3 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1272
diff
changeset
|
6 * |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1272
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
9 * Software engineering by Intevation GmbH |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1272
diff
changeset
|
10 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
11 * Author(s): |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
13 */ |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
14 |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
1703
diff
changeset
|
15 import { logOff } from "@/lib/session"; |
1703
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
16 |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
17 import axios from "axios"; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
18 |
1703
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
19 const UNAUTHORIZED = 401; |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
20 |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
21 const HTTP = axios.create({ |
2992
5f617f25e646
client: removed timeout again, needs clarification
Markus Kottlaender <markus@intevation.de>
parents:
2991
diff
changeset
|
22 baseURL: process.env.VUE_APP_API_URL || "/api" |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
23 /* headers: { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
24 Authorization: 'Bearer {token}' |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
25 }*/ |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
26 }); |
1703
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
27 |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
28 HTTP.interceptors.response.use( |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
29 response => response, |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
30 error => { |
4867
5555b77b8c4e
report backenderror due to failing OL loaders
Thomas Junk <thomas.junk@intevation.de>
parents:
2992
diff
changeset
|
31 if (error.response) { |
5555b77b8c4e
report backenderror due to failing OL loaders
Thomas Junk <thomas.junk@intevation.de>
parents:
2992
diff
changeset
|
32 const { status } = error.response; |
5555b77b8c4e
report backenderror due to failing OL loaders
Thomas Junk <thomas.junk@intevation.de>
parents:
2992
diff
changeset
|
33 if (status === UNAUTHORIZED) { |
5555b77b8c4e
report backenderror due to failing OL loaders
Thomas Junk <thomas.junk@intevation.de>
parents:
2992
diff
changeset
|
34 logOff(); |
5555b77b8c4e
report backenderror due to failing OL loaders
Thomas Junk <thomas.junk@intevation.de>
parents:
2992
diff
changeset
|
35 } |
1703
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
36 } |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
37 return Promise.reject(error); |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
38 } |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
39 ); |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
40 |
d0830ebb3a23
feat: when request answers with 401 the user is redirected to login
Thomas Junk <thomas.junk@intevation.de>
parents:
1362
diff
changeset
|
41 export { HTTP }; |