How to read URL params in custom created nodes inside N8N? as it's not recognizing any default browser side JS option to get URL - server-side-rendering

I am passing some values in URL of n8n,Which is embeded in apllication via Iframe.
My aim is to get those url parameters when I am using the custom node for some automation purpose.
have tried window.location.href but it's not recognising window keyword
I have tried
const url = require('url');
let params = new url.URLSearchParams('token=sjsbjs');
console.log(params.get('token'))
but in this above solution I don't know how to get URL and pass it to URLSearchParams

Related

language change in nextjs without changing url

is there any way to switch language in nextjs without passing language parameter in url like baseurl/ar or baseurl/en ? if I want to change language from dropdown, url should not change.
query parameters are defined by the routes of your api, in this way, when you change the url, a new call is made in the api passing the parameters that were informed in the route.
you can pass objects to the api route, something like:
const response = awai api.get('yourUrl', {language: en})
this way the information will not appear in the url, but this needs to be changed in the backend so that it knows where to get the parameters from.
you can choose to do the translation in json files, and just switch between them too.
Hope this helps.
#NSL

Apigee remove URL string before forwarding request to target

I want to transform a URL before it is redirected to the target, removing a string. I have the following flow in Apigee:
USER -> APIGEE -> APPLICATION -> APIGEE -> USER
The user requests and then its URL should be rewritten removing bar from the URL.
BEFORE apigee.url.com/foo/bar/pBxATaojIn8tk5dvQdNJ
AFTER target.url.com/foo/pBxATaojIn8tk5dvQdNJ
I use Proxy Endpoints and Target Endpoints and try to rewrite using a PreFlow hook with Javascript in the Target Endpoint, without success rewriting the proxy.pathsuffix. How can I solve this?
I now use the following solution:
// Disable copy path
context.setVariable("target.copy.pathsuffix", false);
// Replace string in incoming proxy URL path
var proxyPathSuffix = context.getVariable("proxy.pathsuffix");
var fooBarAfter = proxyPathSuffix.replace('/fooToReplace', '');
// Fetch target outgoing url path
var targetBasePath = context.getVariable("target.basepath");
var urlPath = targetBasePath.concat(fooBarAfter);
// Replace outgoing url
var targetUrl = context.getVariable("target.url");
targetUrl = targetUrl.replace(targetBasePath, urlPath);
context.setVariable("target.url", targetUrl);
I came up with it looking at the available variables here. As this is JS, if someone comes up with a better solution I would be happy!
From my understanding proxy.pathsuffix is a read only variable so you can't override it.
Assign your target endpoint to target.url instead. (I usually use in Assign Message Policy of the request)
Example:
<AssignVariable>
<Name>target.url</Name>
<Ref>yourTargetUrlValue</Ref>
</AssignVariable>
In my Assign Message Policy of the request, I have added the block of code above for defined my target url.
You can assign directly like <Ref>http://test.com</Ref> or assign via variable like <Ref>{targetUrlVal}</Ref>
If you got the url from somewhere, don't forget to assign value to your variable before use it by using context.setVariable("targetUrlVal", "http://test-01.com");
Hopefully my answer will help you.
I solved this similar to how you did it. See my answer on another SO question that answers this.

How can I get custom querystring included in returned firebase dynamic shortlink

I'm using the Firebase dynamic link post API to return a shortlink. When I post this:
https://CENSORED.page.link/?link=https://www.CENSORED.co.uk/offers/friends/?utm_source=referafriend&utm_medium=ecrm&utm_campaign=cbk25&utm_term=988776
clicking the returned shortlink redirects to:
https://www.CENSORED.co.uk/offers/friends/?utm_source=referafriend
The post is made from clientside js. Firebase is returning a working shortlink, but with some parameters missing.
Expected url from clicked shortlink:
https://www.CENSORED.co.uk/offers/friends/?utm_source=referafriend&utm_medium=ecrm&utm_campaign=cbk25&utm_term=988776
Looks like its chopping off most of my querystring - how do I get the full query string returned correctly please?
Solved: Escaping the url worked for me:
params lost:
"https://www.test.co.uk/testing/?utm_source=jam&utm_medium=spoon&utm_campaign=jar&utm_term=lid"
params returned correctly:
"https%3A%2F%2Fwww.test.co.uk%2Ftesting%2F%3Futm_source%3Djam%26utm_medium%3Dspoon%26utm_campaign%3Djar%26utm_term%3Dlid"

Pick a random url from list and display as URL

Im using Visual Studio 2012 and creating a web page using "ASP.NET Web Site (Razor v2)"
Im using Java to generate a random link;
<script>
var random = new Array();
random[0] = "example1.com";
random[1] = "pattern1.com";
random[2] = "specimen1.com";
</script>
<script>
function randomlink() {
window.location = random[Math.floor(Math.random() * random.length)];
}
</script>
A Random URL
When I click the A Random URL link it opens a random page from the list in the script above. I'ts all good, but because its a verry big list I need a way to do the same without having it in HTML because its slowing the loading of the page since its in the _SiteLayout.cshtml. Thanks.
Among your choices are the following options:
Send all the URLs to the client and have the client pick a random choice.
Have the server pre-pick the random URL and send only that one to the client (it can just be put directly into the <a> link. No need for javascript at all.
Make an ajax call to the server to request a random link and when that is returned, go to it.
Make a get request to the server and have the server return a redirect to a randomly chosen URL.
It sounds like you don't want to implement the first option if you have a zillion URLs.
The second option is probably the easiest as it requires only slightly modifying the generation of the page and requires no new server APIs. You just have to figure out how to select a random URL in your server-side environment.
The third and fourth options are the least efficient as they require a call to the server, a response from the server with the new URL and then a client redirect to the actual URL.
I would pass the random url with the page when it renders from the server. You can generate the url on the server using c#'s Random class.
A Random URL
Just pass a model that you reference in your view.

Simulate file form submission with XMLHttpRequest Level 2

On my current page I use old file upload with input element. However, now I've implemented drag&drop from that very nice series of articles: http://www.sitepoint.com/html5-file-drag-and-drop/
There's one snag. Before rewriting the page I was submitting the form with the file and server side service (Java's appspot.com) did all the magic of retrieving the file, saving to DB etc. I would still like to take advantage of that service. However now, after rewriting the file upload to use XMLHttpRequest my code simply writes file to the content, whereas service expects form.
Is there a way to mimick miltipart/form-data form submission with XMLHttpRequest?
The FormData object can be used to submit multipart/form-data forms.
Basic example:
var fd = new FormData(); // Optionally: new FormData(htmlFormElement);
fd.append('key', 'value');
fd.append('file', reference_to_File_object);
// ^ Example: .files property of an <input type="file"
var xhr = new XMLHttpRequest();
xhr.open('post', '/postdata', true);
xhr.send(fd);
When strings are passed to the .send() method of an XMLHttpRequest instance, it is converted to unicode, then encoded as UTF-8. This means that a custom multipart/form-data implementation, using strings, will often not work correctly.

Resources