From feecd66506dddb241fbfab25cd0395555ab636cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 16 Dec 2020 12:00:14 -0500 Subject: [PATCH] fix: api usage --- public/src/client/account/header.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/src/client/account/header.js b/public/src/client/account/header.js index a72422c596..a975025eb0 100644 --- a/public/src/client/account/header.js +++ b/public/src/client/account/header.js @@ -116,11 +116,14 @@ define('forum/account/header', [ } function toggleFollow(type) { - api[type === 'follow' ? 'put' : 'delete']('/users/' + ajaxify.data.uid + '/follow', undefined, () => { + api[type === 'follow' ? 'put' : 'delete']('/users/' + ajaxify.data.uid + '/follow', undefined, function (err) { + if (err) { + return app.alertError(err); + } components.get('account/follow').toggleClass('hide', type === 'follow'); components.get('account/unfollow').toggleClass('hide', type === 'unfollow'); app.alertSuccess('[[global:alert.' + type + ', ' + ajaxify.data.username + ']]'); - }, 'default'); + }); return false; }