0

I have two websites. One website is going to capture form data and put it into a url...

let url = `https://xxxxxxxxxx.herokuapp.com/band/${band._id}?toggle=true&eventDate={"eventDate": ${mainDate[0]}, "eventCharge": ${mainDate[1]}}&quoteAdjuster=${sliderValue}`

Some of the information that I collect in the form is stored in objects and arrays.

Is there a way to send objects/arrays in this url to my website? Currently that whole object above, mainDate, still comes through as a string.

Thanks!

Nick McLean
  • 601
  • 1
  • 9
  • 23

1 Answers1

0

You could change your objects and arrays into strings on purpose by using JSON.stringify(myObject).

Then the server would just need to just use JSON.parse(sentData) in order to reconstruct the arrays and objects (some types of data don't survive this operation, so be careful. For example Date objects become strings and you have to reconstruct them manually).

Also, remember that the GET protocol has a fairly small payload limit (8KB). You will want to switch to using POST, if those parameters aren't important for the URL that the user is browsing.

Adam Jeliński
  • 1,708
  • 1
  • 10
  • 21