File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,10 @@ import Message from './Message.vue';
12
12
export default {
13
13
components: { Message },
14
14
computed: mapGetters ([' messages' , ' lastFetchedMessageDate' ]),
15
- methods:
16
- mapActions ([' fetchMessages' ]),
17
- asyncData ({ store }) {
18
- return store .dispatch (' fetchInitialMessages' )
15
+ methods:
16
+ mapActions ([' fetchMessages' ]),
8000
17
+ asyncData ({ store, context }) {
18
+ return store .dispatch (' fetchInitialMessages' , context . origin )
19
19
}
20
20
}
21
21
</script >
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ export default context => {
11
11
}
12
12
Promise . all ( matchedComponents . map ( Component => {
13
13
if ( Component . asyncData ) {
14
- return Component . asyncData ( { store } )
14
+ return Component . asyncData ( { store, context } )
15
15
}
16
16
} ) )
17
17
. then ( ( ) => {
Original file line number Diff line number Diff line change 1
1
import axios from 'axios'
2
2
3
- export const fetchInitialMessages = ( { commit} ) => {
3
+ export const fetchInitialMessages = ( { commit} , origin ) => {
4
4
// this one will run on server so it need FQDN or server won't able to resolve the API address
5
- return axios . get ( 'http://localhost:5000/ initialMessages' ) . then ( response => {
5
+ return axios . get ( ` ${ origin } / initialMessages` ) . then ( response => {
6
6
commit ( 'INITIAL_MESSAGES' , response . data )
7
7
} ) . catch ( err => {
8
8
console . log ( err )
9
9
} )
10
10
}
11
11
12
12
export const fetchMessages = ( { commit} , lastFetchedMessageDate ) => {
13
- axios . post ( 'http://localhost:5000 /fetchMessages' , {
13
+ axios . post ( '/fetchMessages' , {
14
14
lastMessageDate : lastFetchedMessageDate
15
15
} )
16
16
. then ( response => {
You can’t perform that action at this time.
0 commit comments