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

TypeError: "pageData.items is undefined" #16

Closed
retostadelmann opened this issue Jan 3, 2020 · 8 comments
Closed

TypeError: "pageData.items is undefined" #16

retostadelmann opened this issue Jan 3, 2020 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@retostadelmann
Copy link

grafik

@eddex
Copy link
Owner

eddex commented Jan 6, 2020

Either the API URL has changed or the API itself doesn't return a list of items anymore.

@eddex eddex added the bug Something isn't working label Jan 6, 2020
@eddex
Copy link
Owner

eddex commented Jan 6, 2020

Both suggestions in my previous comment are wrong. The request is still the same but if it is sent by our extension, we get the following response: Object { message: "Authorization has been denied for this request." }...

eddex added a commit that referenced this issue Jan 6, 2020
@eddex
Copy link
Owner

eddex commented Jan 6, 2020

Update: We couldn't figure out why the API call fails sometimes. Most of the time it works just fine. Might be a timing issue or just HSLU doing HSLU stuff..

Version 2.0.6 includes error handling for this issue. A message is shown to the user to inform him that the extension failed to download the necessary data.

Workaround: Wait a few minutes and reload the page.

@eddex eddex closed this as completed Jan 7, 2020
@eddex eddex reopened this Jan 15, 2020
@eddex eddex added the help wanted Extra attention is needed label Jan 15, 2020
@eddex
Copy link
Owner

eddex commented Jan 15, 2020

Reopened because this turned out to be a big issue.

After logging in, the requests of our browser add-on get blocked.
We tried the following things to fix it:

  • Send the request exactly like the page does (with all headers and properties)
  • Reduce the amount of items fetched at the same time
  • Wait a few seconds before we send our request

All of the methods above work (sometimes). If the request is made from the browser console, the requests work more reliably, but also not always. But in the browser add-on nothing fixed the problem.

The only thing that fixes this issue is to stay logged in for 10 - 15 minutes and then reload the page.
Like this, the requests from the browser add-on work without problems (no changes in our code needed)

If anyone has an idea on how to fix this, let us know.

dev-jan added a commit to dev-jan/hslu-simple-mep-results that referenced this issue Jan 21, 2020
The session cookies of the mycampus page have the attribute "sameSite=Lax",
which is the reason they are not included in normal browser extension
requests and the API request will fail (as there is no session active).
@dev-jan
Copy link
Contributor

dev-jan commented Jan 21, 2020

It seems like the session cookie has a new attribute (sameSite=Lax), which only allows the cookie to be send, if the site is the same. As the simple-mep-results plugin runs under another url (something like moz-extension://60a20a9b-1ad4-af49-9b6c-c64c98c37920/, the session will not be passed to the API, as seen in my ZAP proxy screenshot:
screenshot-mycampus-request

Additionally, the session cookie is newly set in the response, as seen here:
screenshot-mycampus-error

My merge request should fix this issue (tested with firefox).

eddex added a commit that referenced this issue Jan 21, 2020
Add correct permissions to fix API fetch error (#16)
@eddex
Copy link
Owner

eddex commented Jan 21, 2020

Thanks @dev-jan! Your pull requests seems to have fixed the issue.

@eddex eddex closed this as completed Jan 21, 2020
@eddex
Copy link
Owner

eddex commented Jan 30, 2020

@retostadelmann
Copy link
Author

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants