JSFiddle - React, Tailwind, and code Playground
by batcave
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
JavaScript
function getStatusCode(data, key = 'code') {
return _.find(data, 'code')[key]
}
const response = {
success: true,
errors: [{
code: '_approval_pending_'
}]
}
console.log(getStatusCode(response.errors))