JSFiddle - React, Tailwind, and code Playground
HTML
<div id="output"></div>
JavaScript
function response(array) {
$('#output').html(JSON.stringify(array));
}
var the_data = {
"cliente": [{
"id": "1",
"nome": "Fulano"
}, {
"id": "2",
"nome": "Ciclado"
}]
};
the_data = {"json": JSON.stringify(the_data), "delay": 2};
var sucesso = function (data) {
response($.map(data.cliente, function (item) {
return {
label: item.id,
value: item.nome
};
}));
};
// Simulação da requisição ajax
$.post("/echo/json/", the_data, sucesso, "json");