Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LINE] Cannot get displayName from context.session.user. #904

Open
jsdryan opened this issue Jun 5, 2021 · 3 comments
Open

[LINE] Cannot get displayName from context.session.user. #904

jsdryan opened this issue Jun 5, 2021 · 3 comments

Comments

@jsdryan
Copy link

jsdryan commented Jun 5, 2021

My code:
2021-06-06_01-29-41

displayName is undefined, and context.session.user has only id and _updatedAt properties.
2021-06-06_01-29-22

How can I get more information about user?

@jsdryan jsdryan changed the title 無法從 context.session.user 取得 displayName Cannot get displayName from context.session.user. Jun 5, 2021
@jsdryan jsdryan changed the title Cannot get displayName from context.session.user. [LINE] Cannot get displayName from context.session.user. Jun 5, 2021
@tw0517tw
Copy link
Collaborator

tw0517tw commented Jun 5, 2021

Bottender didn't get profiles from platform automatically now. If you want to get profile from the use, use context.getProfile() explicitly.

https://bottender.js.org/docs/en/api-line-context#profile-api---official-docshttpsdeveloperslinemeendocsmessaging-apireferenceget-profile
https://developers.line.biz/en/reference/messaging-api/#get-profile

@jsdryan
Copy link
Author

jsdryan commented Jun 6, 2021

Bottender didn't get profiles from platform automatically now. If you want to get profile from the use, use context.getProfile() explicitly.

https://bottender.js.org/docs/en/api-line-context#profile-api---official-docshttpsdeveloperslinemeendocsmessaging-apireferenceget-profile
https://developers.line.biz/en/reference/messaging-api/#get-profile

Thank you!
I can get displayName now by using the code:

const { displayName } = await context.getUserProfile();

Instead of:

const { displayName } = context.session.user;

But I'm wondering why author can get displayName from context.session.user:
2021-06-06_14-18-18
https://ithelp.ithome.com.tw/articles/10222978

@tw0517tw
Copy link
Collaborator

tw0517tw commented Jun 6, 2021

https://github.com/Yoctol/bottender/releases/tag/v1.0.0

[breaking] rename skipProfile to skipLegacyProfile, and set to true by default

This was a breaking change introduced in v1.0.0. Bottender before v1 will automatically get profile and put that into session.user. That option is disabled by default after v1 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants