dylanjha
dylanjha

Reputation: 2523

Node parse raw string into query params

string:

?utm_campaign=My+Campaign+Name&utm_medium=email

I want to turn this into an object:

{    
  utm_campaign: "My Campaign Name",
  utm_medium: "email"
}

I'm trying to find a way to accomplish this with the querystring module but can't seem to do it. Thank you!

Upvotes: 0

Views: 126

Answers (1)

gtsouk
gtsouk

Reputation: 5263

Your problem is the &. It should be & otherwise it is treated as a regular character and not the special character separating query parameters.

Upvotes: 1

Related Questions