Cannot make notion link in discord node

Hi @Shirobachi, woah, that’s a funky one, took me quite a while to figure out.

I was first looking at the MDN page for .replaceAll() (from your screenshot) as I had no idea it exists:

And at the very bottom it has a compatibility matrix, suggesting it’s only supported since Node.js 15. The n8n docker image is however built on Node.js 14.

So what has (most likely) happened here is that your browser supports .replaceAll() (which is why you can see it working in the preview), but the server running n8n doesn’t yet. My suggestion would be to use the more traditional .replace() instead which is supported since Node.js 0.10.

To replace all occurrences of -, you can use a regular expression with the g flag. So instead of:
Link: https://www.notion.so/shirobachi/{{$json["id"].replaceAll('-', '')}}

use:
Link: https://www.notion.so/shirobachi/{{$json["id"].replace(/-/g, '')}}

in your Discord node to get the actual values after /shirobachi/:

1 Like