Created
February 7, 2019 16:02
-
-
Save loraxx753/150dcce59dae3e428110164399cc6367 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
export const getInput = () => new Promise((resolve, reject) => { | |
document.querySelector('form').addEventListener('submit', function listener(e) { | |
e.preventDefault() | |
const inputString = e.target.querySelector('input[type=text]').value | |
resolve(inputString) | |
e.target.removeEventListener('submit', listener) | |
}) | |
}) | |
/* USAGE | |
const credentials = await getInput() | |
const [ username, password ] = credentials.split('|').map(s => s.trim()) | |
console.log(credentials) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment