From 5ca03f2ab7d4747560f82102f27b1cf1fb9010a0 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 7 May 2018 11:07:44 +0200 Subject: Update nextcloud_fetch lib Signed-off-by: Christoph Wurst --- js/service/registration.js | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'js') 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(); -- cgit v1.2.3