I am using real-time Database:
This is a put request in which users generate key onClick. This is working fine.
When a send user login from different device it just replaces the previous user.

It does not add a new user history
import axios from 'axios';
const endPoint = 'https://*_hide_.firebaseio.com/userHistory.json/'
export const UserHistory = (data) => {
let token = localStorage.getItem('token')
return axios.put(endPoint,JSON.stringify(data), {
headers :{
'Content-Type': 'application/json',
'Authorization': 'Bearer'+ token
}
})
}
Calling put on a path replaces any existing value at that path with the value that you specify.
If you want to add a new child node under the path, you should use post instead of put.
If you want to merge the data you specify with any existing values at the path, you should use patch instead of put.
For more on this, also see the Firebase documentation on writing data to the Realtime Database with its REST API.