JSFiddle - React, Tailwind, and code Playground

by 3gwebtrain

JavaScript

var cache = {};

var promise = function( val ){
    return cache[ val ] || $.ajax('https://api.github.com/users/mralexgray/repos', {
        data: { value: val },
        dataType: 'json',
        success: function( resp ){
            cache[ val ] = resp;
        }
    });
};
$.when(promise('repos')).then(function(resp){
    console.log('data is ' + resp );
})