Good afternoon!
I am thrilled to be here today.
My name is Cory and I am a senior web developer at Aumni.
and I am learning Scottish Gaelic. 😄
why yes, we are hiring. thank you for asking
or
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then((pageData) => {
updateAppState(pageData)
if (pageData.user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = pageData.transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then((pageData) => {
updateAppState(pageData)
if (pageData.user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = pageData.transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
response.json()
.then(errorMessage => {
globalErrorToast(`Oh noes! Couldn't get user.`)
log(errorMessage)
done(errorMessage)
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
log(error)
done(error)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
[My app] cannot be reconciled with the idea that [app state] should represent a reality in time and space, free from spooky action at a distance
~ Einstein the software developer
combineReducers(userReducer, transactionsReducer)
...
dispatch({ type: 'user', paylaod: user })
dispatch({
type: 'transactions',
paylaod: transactions
})
combined reducers + dispatch
(props) => {
const [user, setUser] = useState(null)
const [
transactions,
setTransactions
] = useState(null)
...
}
distinct useState/Reducer calls
MyStore.getMyStuff()
MySore.on('change', handler)
YourStore.getYourStuff()
YourSore.on('change', handler)
separate data stores
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (pageData.user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
response.json()
.then(errorMessage => {
globalErrorToast(`Oh noes! Couldn't get user.`)
log(errorMessage)
done(errorMessage)
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
log(error)
done(error)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then((pageData) => {
updateAppState(pageData)
if (pageData.user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = pageData.transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
response.json()
.then(errorMessage => {
globalErrorToast(`Oh noes! Couldn't get user.`)
log(errorMessage)
done(errorMessage)
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
log(error)
done(error)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
A given object should assume as little as possible about the structure or properties of anything else (including its subcomponents).
Stuff goes in
Stuff comes out
Stuff goes in
Stuff comes out
Stuff goes in
Stuff comes out
global scope?
mutations?
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const hasError = (message: MESSAGE_TYPE): boolean => (
message.status === UNKNOWN_ERROR ||
message.status === UNKNOWN_STATUS ||
message.status === ERROR
)
const hasError = (messageStatus: MESSAGE_STATUS_ENUM): boolean => (
messageStatus === UNKNOWN_ERROR ||
messageStatus === UNKNOWN_STATUS ||
messageStatus === ERROR
)
const hasError = (messageStatus: MessageStatusEnum) =>
[UNKNOWN_ERROR, UNKNOWN_STATUS, ERROR].includes(messageStatus)
const hasError = (message: MESSAGE_TYPE): boolean => (
message.status === UNKNOWN_ERROR ||
message.status === UNKNOWN_STATUS ||
message.status === ERROR
)
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataEndpoints, adminRole, done) => {
fetch(pageDataEndpoints[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (user.role === adminRole) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (user.role === adminRole) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (isAdmin(user.role)) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (isAdmin(user)) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (isAdmin(user.role)) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
To produce or obtain (a compound) from another substance
What's a googol minus 1?
- my 7yr old
😅
- Alexa
What's a googol minus 1?
- my 7yr old
999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999
- the answer he was looking for
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (isAdmin(user.role)) {
setIsAdmin(true)
}
const transactionsPreview = transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
if (isAdmin(user.role)) {
setIsAdmin(true)
}
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
A place for everything, and everything in its place
- Benjamin Franklin
Less pure.
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
Promise.resolve(
Promise.resolve(
Promise.resolve(
Promise.resolve(
Promise.resolve(
Promise.resolve(5)
)
)
)
)
).then((val) => console.log(val))
// 5
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => {
if (response.ok) {
response.json()
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok ? response.json() : Promise.reject(response))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok ? response.json() : Promise.reject(response))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok ? response.json() : Promise.reject(response))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok ? response.json() : Promise.reject(response))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get user.`)
log(error)
done(error)
})
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (endpoints, pageName, roles, featureFlags, done) => {
fetch(endpoints.pageData[pageName])
.then((response) => {
if (response.ok) {
response.json()
.then((pageData) => {
updateAppState(pageData)
if (pageData.user.role === roles.admin) {
setIsAdmin(true)
}
const transactionsPreview = pageData.transactions.slice(0, 3)
setTransactionsPreview(transactionsPreview)
done()
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't parse page data.`)
log(error)
done(error)
})
} else {
globalErrorToast(`Oh noes! Couldn't get user.`)
response.text()
.then(errorMessage => {
log(errorMessage)
done(errorMessage)
})
}
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const makeGetPageData = ({
fetch,
updateUser,
updateTransactions,
globalErrorToast,
log
}) => (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
}
const makeGetPageData = ({
fetch,
updateUser,
updateTransactions,
globalErrorToast,
log
}) => (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI, done) => {
fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
done()
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
done(error)
})
}
const getPageData = (pageDataURI) => fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions, ...rest }) => {
updateUser(user)
updateTransactions(transactions)
return { user, transactions, ...rest }
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
})
const tap = (fn) => (value) => {
fn(value)
return value
}
const getPageData = (pageDataURI) => fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(({ user, transactions, ...rest }) => {
updateUser(user)
updateTransactions(transactions)
return { user, transactions, ...rest }
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
})
const getPageData = (pageDataURI) => fetch(pageDataURI)
.then((response) => response.ok
? response.json()
: Promise.reject(response.text()))
.then(tap({ user, transactions }) => {
updateUser(user)
updateTransactions(transactions)
})
.catch((error) => {
globalErrorToast(`Oh noes! Couldn't get page data.`)
log(error)
})
Are there any questions?
thank you
goodbye everyone
and