i am using the npm request module to post data.
by default the posy is of x-www-form-urlencoded
so on the server side i am receiving the data like this
{
'files[0][path]': 'myfile1',
'files[0][contents]': 'some content',
'files[0][active]': 'true'
}
how do i parse the data to json? like
{
files: [{
path: 'mypath',
content: 'mycontent',
active: true
} {
path: 'mypath2',
content: 'mycontent2',
active: false
}]
}
I think express js might use a middle wire for this, but I am using hapi server. what are my options to parse the payload to json?
with bodyparsing on the server side and hapijs, i happen to bump into hapi-bodyparser which did the job.
There are a number of existing node packages that deal with parsing requests. Check out https://www.npmjs.com/package/body-parser-json. To write a solution from scratch would just be a waste of time.
Have you looked into jQuery's serializeArray() api? This might be good enough depending on your use case but here's another library built on top of serializeArray().
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I have 3 parallel promises or api requests once all teh three are done, I need to call another api request based on the second promise and then finally callthen( of $q
I'm new to react and I'm trying to put react-d3-component in the create-react-app boilerplate
As I am learning how to program I find it a bit difficult to piece code togetherSo I joined stackoverflow for more help