Context doesn't work as intended

I am trying to set context of a page. This way below works fine.

{
    path: "/dashboard/",
    async (routeTo, routeFrom, resolve, reject) {
        resolve({
            component: Dashboard
        }, {
            context: {
                userData: JSON.parse(sessionStorage.getItem('userData'))
            }
        })
    }
}

However this does not work. Why do i have to use the convoluted way to set the context?

{
    path: "/dashboard/",
    component: Dashboard,
    options: {
        context: {
            userData: JSON.parse(sessionStorage.getItem('userData'))
        }
    }
},
1 Like