We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7102fec commit 56c8510Copy full SHA for 56c8510
src/ViewProduct.vue
@@ -43,15 +43,25 @@
43
};
44
},
45
created() {
46
- this.product = this.getProduct(this.productId);
+ this.getProduct(this.productId)
47
+ .then(product => this.product = product);
48
49
beforeRouteUpdate(to, from, next) {
- this.product = this.getProduct(to.params.productId);
50
+ this.getProduct(to.params.productId)
51
52
+
53
next();
54
55
methods: {
56
getProduct(productId) {
-
57
+ return this.$http.get('http://localhost:3000/products/{productId}', {
58
+ params: {
59
+ productId: productId
60
+ }
61
+ }).then(
62
+ response => response.json(),
63
+ response => alert("Could not retrieve product!")
64
+ );
65
66
goBack() {
67
this.$router.history.go(-1);
0 commit comments