There is an endpoint called /data
which contains some fields. How can I create a new field in this endpoint?
before:
{
"data": {
"name": "...",
"surname": "..."
}
}
after the api.post('/data', { email })
request, /data
should look like this:
{
"data": {
"name": "...",
"surname": "...",
"email": "..."
}
}
but currently, when I add a new field, the other ones are being deleted:
{
"data": {
"email": "..."
}
}
2
Answers
Because you are only passing email, as mentioned by you:
If you mean appending email in body of post request :
If I understand correctly, you want that the
/data
endpoint remembers the previous REST calls, and simply adds/overwrites object key/values. Because REST is stateless you need a persistent storage to achieve that, such as MySQL, MongoDB, or Memcached.