Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace hand-crafted request token logic by nextcloud-axios lib #11678

Merged
merged 2 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions settings/js/0.settings-vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion settings/js/2.settings-vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion settings/js/2.settings-vue.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion settings/js/3.settings-vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion settings/js/3.settings-vue.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions settings/js/4.settings-vue.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions settings/js/settings-vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion settings/js/settings-vue.js.map

Large diffs are not rendered by default.

49 changes: 19 additions & 30 deletions settings/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion settings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@babel/polyfill": "^7.0.0",
"axios": "^0.18.0",
"nextcloud-axios": "^0.1.2",
"nextcloud-vue": "^0.1.5",
"v-tooltip": "^2.0.0-rc.33",
"vue": "^2.5.17",
Expand Down
25 changes: 6 additions & 19 deletions settings/src/store/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
*
*/

import axios from 'axios';

const requestToken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken');
const tokenHeaders = { headers: { requesttoken: requestToken } };
import axios from 'nextcloud-axios'

const sanitize = function(url) {
return url.replace(/\/$/, ''); // Remove last url slash
Expand Down Expand Up @@ -94,28 +91,18 @@ export default {
});
},
get(url) {
return axios.get(sanitize(url), tokenHeaders)
.then((response) => Promise.resolve(response))
.catch((error) => Promise.reject(error));
return axios.get(sanitize(url));
},
post(url, data) {
return axios.post(sanitize(url), data, tokenHeaders)
.then((response) => Promise.resolve(response))
.catch((error) => Promise.reject(error));
return axios.post(sanitize(url), data);
},
patch(url, data) {
return axios.patch(sanitize(url), data, tokenHeaders)
.then((response) => Promise.resolve(response))
.catch((error) => Promise.reject(error));
return axios.patch(sanitize(url), data);
},
put(url, data) {
return axios.put(sanitize(url), data, tokenHeaders)
.then((response) => Promise.resolve(response))
.catch((error) => Promise.reject(error));
return axios.put(sanitize(url), data);
},
delete(url, data) {
return axios.delete(sanitize(url), { data: data, headers: tokenHeaders.headers })
.then((response) => Promise.resolve(response))
.catch((error) => Promise.reject(error));
return axios.delete(sanitize(url), { data: data });
}
};
1 change: 0 additions & 1 deletion settings/src/store/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

import api from './api';
import axios from 'axios/index';
import Vue from 'vue';

const state = {
Expand Down