Skip to content

Instantly share code, notes, and snippets.

@meshboy
Created December 3, 2018 04:44
Show Gist options
  • Save meshboy/63f394217d5445e0f5f104ff7ef70c62 to your computer and use it in GitHub Desktop.
Save meshboy/63f394217d5445e0f5f104ff7ef70c62 to your computer and use it in GitHub Desktop.
async createRecipe() {
const recipeObject = {
name: this.recipeName,
description: this.description,
difficultyLevel: this.difficultyLevel
? parseInt(this.difficultyLevel)
: 0,
image: this.image,
steps: this.stepsList,
averageTimeForCompletion: this.averageTime
? parseInt(this.averageTime)
: 0
};
await this.$apollo
.mutate({
mutation: query.CREATE_RECIPE_QUERY,
variables: { input: recipeObject }
})
.then(({ data }) => {
this.$router.push({ name: "my-recipes" });
})
.catch(err => {
console.log(err);
this.error =
parseGraphqlError(err) || "Something went wrong. Try again...";
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment