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 mounted() { | |
// Use a relative path to call the API now since our request is proxied. | |
const response = await axios.get("/quote") | |
this.quote = response.data.quote; | |
} |
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
module.exports = { | |
devServer: { | |
// This will forward any request that does not match a static file to localhost:3000 | |
proxy: 'http://localhost:3000' | |
} | |
} |
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
app.get('/quote', (req, res) => { | |
res.set('Access-Control-Allow-Origin', 'http://localhost:8080'); | |
res.send({ | |
quote: "The way to get started is to quit talking and begin doing." | |
}); | |
}) |
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
<template> | |
<div id="app" style="font-size: 24px;"> | |
<p>Quote of the day:</p> | |
<p> | |
{{ quote }} | |
</p> | |
</div> | |
</template> | |
<script> |
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
actions: { | |
async addTodo({ commit }, todo) { | |
// This is a fake function to illustrate the example. | |
const response = await postRequestToTheAPI(todo); | |
if (response.isOk) { | |
commit('ADD_TODO', todo); | |
} | |
} | |
} |
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
<template> | |
<div id="app"> | |
<h1>Todo App</h1> | |
<input type="text" @keyup.enter="addTodo()" v-model="message" placeholder="Add a to-do"> | |
<ul> | |
<li v-for="todo in todos" :key="todo.message"> | |
{{ todo.message }} | |
</li> | |
</ul> | |
</div> |
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
<template> | |
<div id="app"> | |
<h1>Todo App</h1> | |
<ul> | |
<li v-for="todo in todos" :key="todo.message"> | |
{{ todo.message }} | |
</li> | |
</ul> | |
</div> | |
</template> |
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
import Vue from "vue"; | |
import Vuex from "vuex"; | |
Vue.use(Vuex); | |
export default new Vuex.Store({ | |
// This is the state of the application. | |
state: { | |
todos: [ | |
{ |
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
<template> | |
<p>Your name is {{ name }}</p> | |
</template> | |
<script> | |
export default { | |
data() { return { | |
name: "Dirk", | |
} }, | |
} | |
</script> |
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
FROM node:12-slim | |
# Create an app directory in the docker | |
WORKDIR /app | |
# Copy the package.json and package-lock.json. | |
COPY package*.json ./ | |
# Install production dependencies. | |
RUN npm install --only=production |
NewerOlder