-
Im have been working with remix for quite some times, and absolutely love it. my question is, how we set the response header if all we return is just a naked object.. consider this example: export const loader = async ({ request }: LoaderFunctionArgs) => {
const locale = await i18next.getLocale(request)
const { currency } = await handleToken(request)
const gameGroups = getGameGroupRequest({
currency
})
const providerGroups = getProviderGroupRequest({
currency
})
const languageSettings = getLanguageSettingsRequest({
lang: locale
})
const styles = await getStyleRequest()
const webSettings = await getWebSettingsRequest()
const webMeta = await getWebMetasRequest()
const showPromotion = webSettings.data.show_promotion.value
return defer({
locale,
styles: styles.data,
webMeta: webMeta.data,
webSettings: webSettings.data,
languageSettings,
gameGroups,
providerGroups,
ENV: {
API_URL: process.env.API_URL ?? '',
API_KEY: process.env.API_KEY ?? ''
}
}, {
headers: {
'Set-Cookie':await promotionTokenCookie.serialize(showPromotion)
}
})
} and if we return naked object, it would be: export const loader = async ({ request }: LoaderFunctionArgs) => {
const locale = await i18next.getLocale(request)
const { currency } = await handleToken(request)
const gameGroups = getGameGroupRequest({
currency
})
const providerGroups = getProviderGroupRequest({
currency
})
const languageSettings = getLanguageSettingsRequest({
lang: locale
})
const styles = await getStyleRequest()
const webSettings = await getWebSettingsRequest()
const webMeta = await getWebMetasRequest()
const showPromotion = webSettings.data.show_promotion.value
return {
locale,
styles: styles.data,
webMeta: webMeta.data,
webSettings: webSettings.data,
languageSettings,
gameGroups,
providerGroups,
ENV: {
API_URL: process.env.API_URL ?? '',
API_KEY: process.env.API_KEY ?? ''
}
}
} Much appreciate any kind of advice... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There's a |
Beta Was this translation helpful? Give feedback.
There's a
data
helper that does the same thing