diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/service/registration.js | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/js/service/registration.js b/js/service/registration.js index eee2dd4..a6aa230 100644 --- a/js/service/registration.js +++ b/js/service/registration.js @@ -1,15 +1,10 @@ import $ from 'jquery'; -import fetch from 'nextcloud_fetch'; +import { nc_fetch_json } from 'nextcloud_fetch'; export function getState() { let url = OC.generateUrl('/apps/twofactor_sms/settings/verification') - return fetch(url, { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - } - }).then(function (resp) { + return nc_fetch_json(url).then(function (resp) { if (resp.ok) { return resp.json(); } @@ -20,12 +15,8 @@ export function getState() { export function startVerification() { let url = OC.generateUrl('/apps/twofactor_sms/settings/verification/start') - return fetch(url, { - method: 'POST', - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - } + return nc_fetch_json(url, { + method: 'POST' }).then(function (resp) { if (resp.ok) { return resp.json(); @@ -37,15 +28,11 @@ export function startVerification() { export function tryVerification(code) { let url = OC.generateUrl('/apps/twofactor_sms/settings/verification/finish') - return fetch(url, { + return nc_fetch_json(url, { method: 'POST', body: JSON.stringify({ verificationCode: code - }), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json' - } + }) }).then(function (resp) { if (resp.ok) { return resp.json(); |