could someone criticize me this approach:
I want to send a JSON object in a GET method but the body is not available, so I'm encoded the JSON in the client and decoded in the server, like this:
// on client
let query = {
subject: subject,
sources: sources
}
query = encodeURIComponent(JSON.stringify(query))
console.log(encoded);
// on server
const { query } = url.parse(req.url)
decodedQuery = decodeURIComponent(query)
it just works, but people use several libraries like querystring and query-string or manually build the query string.
So why don't do what I'm doing?
Regards
Aucun commentaire:
Enregistrer un commentaire