Formatting String For Network Request (JavaScript) -
here dilemma: need format body of post request example below, , quotation marks important.
'{"url":"https://upload.wikimedia.org/wikipedia/commons/d/de/bananavarieties.jpg"}' although, pass value url instead of having hardcoded in.
i have tried using:
const uriinquotes = "'"+uri+"'"; '{"url":+uriinquotes+}' but format still not correct. anyway can go doing this? quotation marks formatted?
thanks in advance.
just use json.stringify() convert object valid json string looks need post.
let requestbody = { url: 'https://upload.wikimedia.org/wikipedia/commons/d/de/bananavarieties.jpg' }; return json.stringify(requestbody);
Comments
Post a Comment