This file contains hidden or 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
[ | |
{ | |
"name": "Afghanistan", | |
"dial_code": "+93", | |
"code": "AF" | |
}, | |
{ | |
"name": "Aland Islands", | |
"dial_code": "+358", | |
"code": "AX" |
This file contains hidden or 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
const initialState = Map({ | |
is_loading: false, | |
is_finish: null, | |
error: { | |
code: '', | |
message: '', | |
}, | |
}); | |
const formReducer = (state = initialState, action) => { |
This file contains hidden or 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
// | |
// .... sisa aplikasi | |
//fungsi render | |
render() { | |
const { formReducer } = this.props; | |
// cek kalau field error ada isinya | |
const isError = formReducer.get('error').size > 0 | |
// kalau mau render full page error atau redirect tinggal : |
This file contains hidden or 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
// sisa dari aplikasi kita | |
//fungsi render | |
render() { | |
//alternative 1, mapping di render | |
const { formReducer, loginReducer, postReducer, errorList } = this.props; | |
//bisa di masukin array dulu sih kalau mau, tapi saya prefer ini | |
//karena masih reasonable untuk di stack di if | |
if (formReducer.get('error') || | |
loginReducer.get('error') || |
This file contains hidden or 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
const errorMessage = (state = null, action) => { | |
const { type, error } = action | |
if (type === ActionTypes.RESET_ERROR_MESSAGE) { | |
return null | |
} else if (error) { | |
return error | |
} | |
return state |
This file contains hidden or 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
export const succesFetch () { | |
// fungsi succes fetch | |
} | |
// here we put the magic. fungsi failedFetch | |
export const failedFetch(message) { | |
return { | |
type: FETCH.FAILED, | |
error: { | |
type: 'FETCH ERROR', |
This file contains hidden or 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
var mediaJSON = { "categories" : [ { "name" : "Movies", | |
"videos" : [ | |
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ], | |
"subtitle" : "By Blender Foundation", | |
"thumb" : "images/BigBuckBunny.jpg", | |
"title" : "Big Buck Bunny" | |
}, | |
{ "description" : "The first Blender Open Movie from 2006", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ], |
This file contains hidden or 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
const request = require('request-promise'); | |
function getPredictionList(searchQuery, key) { | |
const url = `https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${searchQuery}&type=geocode&key=${key}`; | |
request(url) | |
.then(result => { | |
console.log(result); | |
}) | |
.catch(err => console.log(err)); | |
} |
This file contains hidden or 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
const request = require('request-promise'); | |
function getPredictionList(searchQuery, key) { | |
const url = `https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${searchQuery}&type=geocode&key=${key}`; | |
return request(url) | |
} |
This file contains hidden or 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
function getPlaceDetails(placeId, key) { | |
const url = `https://maps.googleapis.com/maps/api/place/details/json?placeid=${placeId}&key=${key}`; | |
return request(url); | |
} | |
getPlaceDetails('ChIJIe0SGpQNuC0RxXX30MzCZ2k', 'Your_api_key').then(result => { | |
console.log(result); | |
}); |
OlderNewer