Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138307

how to encode input text data in html before calling api using axios in reactjs redux app

$
0
0

In my react app i have lot of places where we collect data from end user but we haven't used forms anywhere .

And at few places this input data goes as querystring in the uri and if we don't encode the input data the inputs entered with uri reserved keywors like (&,+,/,=) are causing api errors.

Is there a way we can ecnode input html element data just by specifying an attribute ?

I know two possible solutions .

One use encodedUriComponent("input data") while constructing axios http uri.

Second option is to use form controls enctype with application/x-www-form-urlencoded.

I am not sure whats the best way to encode the data before passing it in uri query string . And is form control with application/x-www-form-urlencodedsame as encodedUriComponent("input data") ?


Viewing all articles
Browse latest Browse all 138307

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>