mirror of
https://github.com/KevinMidboe/planetposen.git
synced 2025-10-29 17:50:32 +00:00
Changed api calls to check for localhost.
This commit is contained in:
@@ -29,6 +29,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
let url = '/api/products'
|
||||||
|
if (window.location.href.includes('localhost'))
|
||||||
|
url = 'http://localhost:30010'.concat(url)
|
||||||
|
|
||||||
fetch('http://localhost:30010/api/products')
|
fetch('http://localhost:30010/api/products')
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.then(products => this.products = products)
|
.then(products => this.products = products)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<p>New bags are on sale every monday. Grab one now while they're in stock!</p>
|
<p>New bags are on sale every monday. Grab one now while they're in stock!</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="products && products.length" class="products">
|
<div v-if="products && products.length" class="products">
|
||||||
<product-card v-for="product in products" :product="product" />
|
<product-card v-for="product in products" :product="product" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span v-else>
|
<span v-else>
|
||||||
@@ -27,7 +27,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
fetch('http://localhost:30010/api/products')
|
let url = '/api/products';
|
||||||
|
if (window.location.href.includes('localhost'))
|
||||||
|
url = 'http://localhost:30010'.concat(url)
|
||||||
|
|
||||||
|
fetch(url)
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.then(products => this.products = products)
|
.then(products => this.products = products)
|
||||||
.then(_ => this.products = this.products.concat(this.products))
|
.then(_ => this.products = this.products.concat(this.products))
|
||||||
|
|||||||
Reference in New Issue
Block a user