M
M
Mikhail0072021-07-30 18:18:49
React
Mikhail007, 2021-07-30 18:18:49

How to add object to array in json-server, axios?

"usersData": [
    {
      "id": 0,
      "email": "[email protected]",
      "password": "qwerty1",
      "name": "John Smith",
      "image": "image/photoUser.png",
      "friends": []
    }
]

how to add object to friends array via json-server and axios
axios.post(' localhost:3001/usersData?id=0/friends ', obj) doesn't work like that

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
black1277, 2021-07-30
@black1277

axios({
  method: 'post',
  url: '/usersData',
  data: {
    firstName: 'Fred',
    lastName: 'Flintstone'
  }
});

pass whatever you want in the data field

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question