JSFiddle - React, Tailwind, and code Playground

by Dovy Paukstys

HTML

<script src="http://rawgithub.com/rootsdev/familysearch-javascript-sdk/master/familysearch-javascript-sdk.js"></script>
<a id="run" href="#">Run</a>
<div id="output" />

JavaScript

function run() {
  FamilySearch.getAccessToken().then(function (response) {
      FamilySearch.getPersonWithRelationships('KW7S-V72', ['persons']).then(function (response) {
        console.log('makePerson', makePerson(response));
        
          function makePerson(response) {
              if (!response) {
                  return;
              }
              return extend({
                  fathers: map(response.getFathers(), getAttrs),
                  mothers: map(response.getMothers(), getAttrs),
                  spouses: map(response.getSpouses(), function(p) {
                      return extend({
                          children: map(response.getChildren(p.getId()), getAttrs)
                      }, getAttrs(p));
                  })
              }, getAttrs(response.getPrimaryPerson()));
          }
          
          function getAttrs(person) {
              return extend({
                  id: person.getId(),
                  living: person.isLiving(),
                  given: person.getGivenName(),
                  surname: person.getSurname(),
                  birth: {  // getDisplayAttrs() includes birthDate and birthPlace, so this is redundant
                      date: person.getBirthDate(),
                      place: person.getBirthPlace()
                  },
                  death: {  // getDisplayAttrs() includes deathDate and deathPlace, so this is redundant
                      date: person.getDeathDate(),
                      place: person.getDeathPlace()
                  }
              }, person.getDisplayAttrs());
          }
    });
  });
}
                                     
FamilySearch.init({
  app_key: 'WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK',
  environment: 'sandbox',
  auth_callback: 'http://fiddle.jshell.net',
  http_function: $.ajax,
    save_access_token: true,
  deferred_function: $.Deferred
});

$('#run').click(run);

function output(label, value) {
    $('#output').append((label ? '<b>' + label +...