0

How can I get a param value from a 'application/x-www-form-urlencoded' request?

Like this response:

param1=value1&param2=value2

How can I do something like above?

var valueOfParam1 = request.body.params['param1'] 
Victor Soares
  • 757
  • 1
  • 8
  • 34
  • nodejs backend? – Ezekiel Oct 19 '19 at 22:39
  • Java backend. But I'm trying to get this value in an Angular incerteptor before send the request. So the backend is irrelevant – Victor Soares Oct 19 '19 at 22:40
  • Well to start with you're the one sending the values right? why wait to intercept when it's generated from your end? secondly do you already have access to it when intercepted? and you simply want to transform into an object like manner right? – Ezekiel Oct 19 '19 at 22:43
  • I send the values. But this interceptor catch multiple requests and I need to identify witch request it is before I send. I have the acces to the body string but I'm not knowing how to get one specifc param – Victor Soares Oct 19 '19 at 22:46
  • okay I will share a code, someone wrote specifically for this, I would have shared a library u wrote that's similar but I wrote it with cookie in mind, but can still be applied – Ezekiel Oct 19 '19 at 22:49

1 Answers1

0

here is a quick solution done by someone here on stackoverflow check his link

https://stackoverflow.com/a/1131651/8594737

You can also check my library tho it serves for a different purpose, but might be useful to understand and explore incase of a more complex scenario

https://github.com/zico4reel/conversionTracker

I hope these links are helpful

Ezekiel
  • 671
  • 5
  • 13