Skip to content

Instantly share code, notes, and snippets.

@yogieputra8
Created February 8, 2018 13:22
Show Gist options
  • Save yogieputra8/ab69804f14b64024b93cf0615b1621f1 to your computer and use it in GitHub Desktop.
Save yogieputra8/ab69804f14b64024b93cf0615b1621f1 to your computer and use it in GitHub Desktop.
import axios from 'axios'
export const FETCH_DATA = 'FETCH_DATA'
export const fetchData = () => {
return {
type: FETCH_DATA
}
}
export const FETCH_DESTINATION = 'FETCH_DESTINATION'
export const fetchDest = () => {
return {
type: FETCH_DESTINATION,
payload: getDataDestination()
}
}
const getDataDestination = async () => {
const url_api_dest = 'http://172.104.50.9:3000/api/destination_lists'
return axios.get(url_api_dest)
.then(res => {
return res.data
})
.catch(err => {
console.log(err)
})
}
export const FETCH_BANNERS = 'FETCH_BANNERS'
export const fetchBanners = () => {
return {
type: FETCH_BANNERS,
payload: getBanner()
}
}
const getBanner = async () => {
const url_banners = `http://172.104.50.9:3000/api/banner_lists`
return axios.get(url_banners)
.then(res => {
console.log(res.data)
return res.data
})
.catch(err => {
console.log(err)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment