fixed api bug

master
A1Gard 3 days ago
parent 48b6e24cee
commit 30c067c12c

@ -5,7 +5,7 @@ window.addEventListener('load', function () {
document.querySelectorAll('.fav-btn')?.forEach(function (el) { document.querySelectorAll('.fav-btn')?.forEach(function (el) {
el.addEventListener('click', async function () { el.addEventListener('click', async function () {
let resp = await axios.get(favUrl+this.getAttribute('data-slug')); let resp = await axios.get(favUrl+this.getAttribute('data-slug'));
if (resp.data.success){ if (resp.data.OK){
this.setAttribute('data-is-fav',resp.data.data); this.setAttribute('data-is-fav',resp.data.data);
window.$toast.success(resp.data.message); window.$toast.success(resp.data.message);
}else { }else {
@ -16,7 +16,7 @@ window.addEventListener('load', function () {
document.querySelectorAll('.compare-btn')?.forEach(function (el) { document.querySelectorAll('.compare-btn')?.forEach(function (el) {
el.addEventListener('click', async function () { el.addEventListener('click', async function () {
let resp = await axios.get(compUrl+this.getAttribute('data-slug')); let resp = await axios.get(compUrl+this.getAttribute('data-slug'));
if (resp.data.success){ if (resp.data.OK){
window.$toast.success(resp.data.message); window.$toast.success(resp.data.message);
}else { }else {
window.$toast.error("Error!"); window.$toast.error("Error!");
@ -28,7 +28,7 @@ window.addEventListener('load', function () {
el.addEventListener('click', async function (e) { el.addEventListener('click', async function (e) {
e.preventDefault(); e.preventDefault();
let resp = await axios.get(this.getAttribute('href')); let resp = await axios.get(this.getAttribute('href'));
if (resp.data.success){ if (resp.data.OK){
window.$toast.success(resp.data.message); window.$toast.success(resp.data.message);
document.querySelectorAll('.card-count')?.forEach(function (el2) { document.querySelectorAll('.card-count')?.forEach(function (el2) {
el2.innerText = resp.data.data.count; el2.innerText = resp.data.data.count;

Loading…
Cancel
Save