Created
December 3, 2018 04:44
-
-
Save meshboy/63f394217d5445e0f5f104ff7ef70c62 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 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