diff options
author | Mark Powers <mark@marks.kitchen> | 2021-01-05 20:25:10 -0600 |
---|---|---|
committer | Mark Powers <mark@marks.kitchen> | 2021-01-05 20:25:10 -0600 |
commit | 5b5dc610bc0da17fd006982de50b4dc74b134a54 (patch) | |
tree | ff474a8cdbac4f3867a7b7983e20146929fa8eb5 /src/js/like.js | |
parent | f2d7673d9743676fcd01d7ab26e7e60d9e21bc8f (diff) |
Refactor likes to use JS to avoid redirect
Diffstat (limited to 'src/js/like.js')
-rw-r--r-- | src/js/like.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/js/like.js b/src/js/like.js new file mode 100644 index 0000000..cd1e015 --- /dev/null +++ b/src/js/like.js @@ -0,0 +1,11 @@ +function likePost(type, id){ + fetch(`/post/like/${type}/${id}`) + .then(response => response.json()) + .then(response => { + console.log(response) + let btn_id=`btn_${type}_${id}` + let el = document.getElementById(btn_id) + el.innerText = `👍 (${response.likes})` + }) +} + |