Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // An array, object or any data (eg. from an ajax call)
- let errorCodes = ['ErrorCode1', 'ErrorCode2', 'ErrorCode3', 'ErrorCode4', 'ErrorCodeBusiness']
- let response = {
- meta:
- {
- version: "1.0",
- time: "2017-07-20 08:28 AM GMT"
- },
- errors:
- {
- errors:
- [
- {
- id: null,
- code: "ErrorCodeBusiness",
- message: "",
- uuid: ""
- }
- ],
- warnings: null
- }
- };
- //Find the error code that starts with given set of errors
- const hasError = _.find(response.errors.erorrs, (error) => {
- _.some(errorCodes, (code) => _.startsWith(code,error.code))
- })
- console.log(hasError);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement