getFirestore
and getFirebase
middleware from the "redux-firestore" and "react-redux-firebase" library respectivelyvalidatonResults
to users/uid
(see comment in code below)firebase.push('users', { data: validatonResults })
import inputValidationAPI from "../../apis/inputValidationAPI"
export const validateTestCase = payload => {
return (dispatch, getState, { getFirebase, getFirestore }) => {
const fireStore = getFirestore()
const firebase = getFirebase()
const uid = getState().firebase.auth.uid
inputValidationAPI
.post("/submitTerm", {
term: payload
})
.then(response => {
return response.data.data
})
.then(validatonResults => {
/*
validationResults = ["string1", "string2", "string3"]
I want to take validationResults and add them into firebase collection something like:
firebase.push('todos/${uid}', { some: 'data' })
*/
return validatonResults
})
.then(validatonResults => {
dispatch({
type: "VALIDATE_TESTCASE_SUCCESS",
payload: validatonResults
})
})
.catch(err => console.log(err))
}
}
The following syntax solved this:
fireStore.update(
{ collection: "users", doc: uid },
{ dataToSave: someJSONObject },
}
)