I have an array of form objects and I have like to get the url in the form objects if it met a condition. I tried like below:
<div
onClick={() =>
(location.href = `${_.filter(forms, function (form) {
console.log('url 84390')
console.log(row.form_id)
console.log(form.id)
if (form.id === row.form_id) {
console.log(form.formUrl). //form.formUrl is correctly printed out /staff/forms/xgcba
return form.formUrl
}
})}`)
}
>
{row.form_id}
</div>
However, I got the error as below:
No route matches [GET] "/staff/[object%20Object]"
I think form.formUrl is not correctly assigned to location.href. Any help would be greatly appreciated.
It works as below.
const handleUrl = (row) => {
forms.map((form) => {
if (form.id === row.form_id) {
location.href = form.formUrl
}
})
}