Skip to content

Instantly share code, notes, and snippets.

@pwxcoo
Created October 6, 2018 06:08
Show Gist options
  • Save pwxcoo/407217756ae71700e0352e6721ab3912 to your computer and use it in GitHub Desktop.
Save pwxcoo/407217756ae71700e0352e6721ab3912 to your computer and use it in GitHub Desktop.
Simple fetch() sample
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