R
Reactiflux

Enfield-li – 18-14 Feb 9

Enfield-li – 18-14 Feb 9

EEnfield-Li2/9/2022
Guys, Please help me out, I am not able to get the return value of this code Only got undefined from both values, but why.. let err = { someJunk: "asdfklasdf", detail: "email is bad" }; let fields = ["username", "email"]; const validation = (errDetail, fields) => { fields.forEach((field) => { if (errDetail.includes(field)) { console.log("caught email"); return { errors: { field: field, message: field + "already taken" } }; } return; }); }; const res = validation(err.detail, fields); console.log(res); https://codesandbox.io/s/crimson-framework-yn9i1?file=/src/index.js
UUUnknown User2/9/2022
2 Messages Not Public
Sign In & Join Server To View
EEnfield-Li2/9/2022
I want to return a single error object when the function caugth a match, so this is not the way I should be doing? So calling return in forEach will not work? I might do a different logic with it.. Just figured out, thanks man!😬
UUUnknown User2/10/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

Enfield-li – 18-14 Feb 9

Join Server