Pass value from KOA to React

Highlighted
New Member
1 0 0

Hello,

I am trying to figure out how to get the locale value passed on from KOA to React.
Im using the Shopify CLI boiler plate code.

I manage to capture the value in this route which is triggered when redirected after auth.

router.get("/", verifyRequest(), async ctx => {
await handle(ctx.req, ctx.res);
console.log('Locale:'+ctx.query.locale);
ctx.respond = false;
ctx.res.statusCode = 200;
});
But I cannot figure out how I can access this value from the react part of the app. I tried with a cookie but it doesnt seem possible to set a cookie from the route giving the following error "Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client". 
What is the best way to pass this value?
 
0 Likes