И
вот сам экшен:
export const sendMessage = (content, id, messageId) => {
return (dispatch) => {
fetch(
https://api.intocode.ru:8001/api/messages/5f2ea3801f986a01cefc8bcd/${id}
, {method: 'POST',
body: JSON.stringify({
_id: messageId,
content,
toUserId: id,
type: "text",
fromUserId: messageId
}),
})
.then(res => res.json())
.then(json => {
dispatch({
type: 'message/add/succeed',
payload: json
})
})
}
}
