Created
April 1, 2020 01:22
-
-
Save manakuro/88ae09cb986f40c58477a50cd06ca309 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const generateQuery = (params) => { | |
const query = {} | |
try { | |
if (params.email) { | |
const isValid = isValidEmail(params.email) | |
if (isValid) { | |
query.email = params.email | |
} | |
} | |
const defaultMaxAgeLimit = JSON.parse(localStorage.getItem('defaultMaxAgeLimit') || '') | |
if (params.maxAge) { | |
if (params.maxAge < 25) { | |
query.maxAge = params.maxAge | |
} | |
} else { | |
query.maxAge = defaultMaxAgeLimit | |
} | |
if (params.limit) { | |
query.limit = params.limit | |
} | |
// do a lot of things here | |
// ... | |
} catch(err) { | |
// error handing | |
} | |
return query | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment