-
-
Save parzibyte/da85794b01a3bef8b9d781f226758c34 to your computer and use it in GitHub Desktop.
This file contains 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
async save() { | |
if (!this.game.name) { | |
return this.$toasted.show("Please write name", { | |
position: "top-left", | |
duration: 1000, | |
}); | |
} | |
if (!this.game.price) { | |
return this.$toasted.show("Please write price", { | |
position: "top-left", | |
duration: 1000, | |
}); | |
} | |
if (!this.game.rate) { | |
return this.$toasted.show("Please write rate", { | |
position: "top-left", | |
duration: 1000, | |
}); | |
} | |
const payload = JSON.stringify(this.game); | |
const url = SERVER_URL + "/game"; | |
const r = await fetch(url, { | |
method: "PUT", | |
body: payload, | |
headers: { | |
"Content-type": "application/json", | |
} | |
}); | |
const response = await r.json(); | |
if (response) { | |
window.location.href = "./get.html"; | |
} else { | |
this.$toasted.show("Something went wrong. Try again", { | |
position: "top-left", | |
duration: 1000, | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment