Created
May 27, 2022 17:51
-
-
Save EduardoRodriguesF/83e550b78ed8ac7804becf010cd4ae4b to your computer and use it in GitHub Desktop.
Gets many entries from VTEX MasterData and deletes all of it. (max of 100 entries per call) - DO NOT USE IT ON FRONT-END, IT WAS MADE TO USE IN DEVTOOLS WHEN NEEDED.
This file contains 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
function deleteManyEntries(dataEntity, appKey, appToken) { | |
const headers = { | |
'X-VTEX-API-AppKey': appKey, | |
'X-VTEX-API-AppToken': appToken, | |
} | |
$.ajax({ | |
url: `/api/dataentities/${dataEntity}/scroll?_fields=id`, | |
headers, | |
success: function(data) { | |
console.log('>>>>>> data to be deleted', data); | |
data.forEach(({ id }) => { | |
console.log('>>> id to delete', id); | |
$.ajax({ | |
url: `/api/dataentities/${dataEntity}/documents/${id}`, | |
headers, | |
type: 'DELETE', | |
success: () => console.log('> deleted', id), | |
}) | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment