Created
October 6, 2018 06:08
-
-
Save pwxcoo/407217756ae71700e0352e6721ab3912 to your computer and use it in GitHub Desktop.
Simple fetch() sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch(`/api/following/`, { | |
method: "POST", | |
headers:{ | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
followerUsername: loginName, | |
followingUsername: nowname | |
}) | |
}) | |
.then(res => res.json().then(data => ({status: res.status, body: data}))) | |
.then(res => { | |
if (res.status === 200 && res.body === true) { | |
this.status = 'unfollow' | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment