Home > front end > Axios pass an array as problems get request? Hk []=[1, 2, 3]
Axios pass an array as problems get request? Hk []=[1, 2, 3]
Time:11-04
Axios use get the params transfer directly into an array of
I write so
Var nk=[1, 2, 3] Axios. Get (urlStr, { Params: { Hk: nk } })
Single request url is joining together for localhost: 8080/API/? Hk []=[1, 2, 3] Turned into a 400 illegal format how to splice it into the right localhost: 8080/API/? Hk=1 & amp; Hk=2 & amp; Nk=3
Thank you all for this problem has been bothering me for days
CodePudding user response:
You look it
CodePudding user response:
This is handle by yourself, don't put params went inside, his hand in the url to deal with the
Var nk=[1, 2, 3] UrlStr +=? Nk. ForEach (e=& gt; { UrlStr +="hk=" + e + "& amp;" }) UrlStr=urlStr. Replace (/& amp; $/, "") Axios. Get (urlStr)