I have some string like this
const resultComing ='access_token=test&token_type=bearer&state=state&expires_in=43199&scope=test';
I need to passed to object that will look like this
const result: any = {
access_token: test,
token_type: bearer,
state: state,
expires_in: 43199,
scope: test
};
I have tried like this
const result: any = resultComing.split('&').reduce(function (result: any, item: string) {
const parts = item.split('=');
result[parts[0]] = parts[1];
}, {});
But i got error, TypeError: Cannot set property 'token_type' of undefined