frencojobs / vscode-notion

Browse Notion pages right inside Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=frenco.vscode-notion
MIT License
327 stars 15 forks source link

Not being able to open Notion pages. #4

Closed yaripey closed 3 years ago

yaripey commented 3 years ago

Hi there. I can't open anything from Notion with this extension. For example, this page. I can open it in browser, but the VSCode just shows VSCode Notion: Loading... in the bottom right corner for 2-3 seconds and dissapears. Nothing else happens. Maybe I need to provide some additional info?

frencojobs commented 3 years ago

Hmmm, that page loads and works perfectly well for me though.

proof

It might not be related to the webview if the tab doesn't open at all. If so can you check and share the error log in the console if any exists? You can open the console from Help > Toggle Developer Tools.

alawler4 commented 3 years ago

I'm having a similar problem. The test page opens just fine, but a non-test page doesn't do anything.

yaripey commented 3 years ago

It gives me this:

image

stwgabriel commented 3 years ago

I'm having the same problem!

stwgabriel commented 3 years ago

image

frencojobs commented 3 years ago

Does the error persist? I mean

And can you guys open this URL https://notion-api.frenco.dev/v1/page/320213fb70ba48169059a17fa9dc195c? To check if it's caused by the server in your VPN area or not.

yaripey commented 3 years ago
  1. No, error is happening to all pages. I tried like 10 of different ones, same result.
  2. Yes, the error is the same after a lot of tries.
  3. Yes, it basically adds two commands to comand pallette, you give it a link, it shows a message of loading and then never does anything else.

And yes, the link is openable in any browser. It returns a JSON with info about the page.

frencojobs commented 3 years ago

It is definitely a weird bug, it's not reproducible on my machine, and according to the log, the error comes from this line

if (Object.keys(res.data).length < 1) {
  throw new Error("Couldn't load the data from API.")
}

which is only the case when the data return from API looks like this,

{}

If viewing the API in the browser doesn't look like that, it's super weird. Then, the only case possible would be that res.data is null. I have no idea why it would be though.

May I know your VSCode version, and basic information about your machine model so that I can go through VSCode issues and check for one similar to the case? You can get the version from code -v.

yaripey commented 3 years ago

Results from code -v:

1.52.1
ea3859d4ba2f3e577a159bc91e3074c5d85c0523
x64

Here is my VSCode about text.

image

My machine is Huawei MateBook D14, AMD Ryzen 5 3500U.

Though, there are other people who has the same bug, I doubt there is something to do with the machine.

frencojobs commented 3 years ago

Omg I think I know what the error is. I parse the notion URL to get the ID using a regex something like this,

const pattern = /(?:https?:\/\/)?(?:www\.)?notion\.so\/([\w\.-]*)*\/?/

so it only matches public links without a username, so you have to use it as

# like this
https://www.notion.so/Test-page-for-VSCode-notion-extension-320213fb70ba48169059a17fa9dc195c
# not like this
https://www.notion.so/yaripey/Test-page-for-VSCode-notion-extension-320213fb70ba48169059a17fa9dc195c

You can get the absolute URL from the Share > Copy Link in Notion.

frencojobs commented 3 years ago

v1.0.1 will contain a fix for this, by parsing URLs containing usernames. Feel free to reopen the issue if you think it's not the culprit after trying in v1.0.1.

yaripey commented 3 years ago

Yes! Without username it works fine. The only note I would like to make is that Share > Copy Link still adds username to the path, at least for me. So the only way to obtain a working absolute link is to remove the username from the path manually. Good to hear that it will be fixed in v1.0.1, waiting for it. Thanks.

harshraj1311 commented 2 years ago

GETTING ERROR AGAIN! error is = "Couldn't load the data from API. "

JQuezada0 commented 2 years ago

Same

nomm-dot commented 1 year ago

Currently getting the same issue, but when copying the link in notion there is no user or file path to change. I copy and paste to VScode and I get the "Couldn't load the date from API" or "Request failed with status code 404" errors in the bottom right corner. I am not running a VPN. I tried to publish the page and add it to a workgroup neither resolved the issue.