javascript - Extra quotes in response.text() -
in react/redux app, make call backend api returns text response. use following line retrieve text. issue i'm seeing code seems put 2 sets of quotes around text receive.
so, api returns hello world! in code below becomes ""hello world!""
my api returning string there set of quotes around text such "hello world!" fine. don't understand why i'm getting 2 sets of quotes.
any idea why?
export const callapi = (request) => { return (dispatch) => fetch('/api/getsometext', fetchoptionspost(request)) .then((response) => { if(!response.ok) { // request failed dispatch(setbadrequest(true)) } else { const mytext = response.text() // i'm getting double quotes .then((mytext) => dispatch(setmytext(mytext))) } }) }
i think should check , test api using tools postman.
Comments
Post a Comment