Created
September 26, 2020 03:59
-
-
Save FelipeBarrosCruz/b2b87f467f8c128b53e02879dfb5f894 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 NEW_VALUE = 1 | |
| const forms = document.querySelectorAll('form') | |
| const save = ({ input, submit }) => new Promise(async(resolve, reject) => { | |
| try { | |
| input.value = NEW_VALUE | |
| await submit.click() | |
| resolve() | |
| } catch (err) { | |
| reject(err) | |
| } | |
| }) | |
| const promises = [...forms].map(form => save({ | |
| input: form.querySelector('input[type="number"]'), | |
| submit: form.querySelector('input[type="submit"]'), | |
| })) | |
| Promise.all(promises) | |
| .then(() => alert('Todas concluídos')) | |
| .catch(err => { | |
| alert('Error, verificar o console do navegador') | |
| console.log(err) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment