Skip to content

Instantly share code, notes, and snippets.

View subramaniashiva's full-sized avatar

Siva Subramaniam subramaniashiva

View GitHub Profile
fetch('https://images-api.nasa.gov/search?q=galaxy')
.then(response => response.json())
.then(data => console.log(data))
.catch(err => console.log(err));
// Create a new XMLHttpRequest Object
const xhr = new XMLHttpRequest();
// Initialize the object by calling open method
xhr.open('GET', 'https://images-api.nasa.gov/search?q=galaxy');
// Track the state changes of the request.
xhr.onreadystatechange = function () {
const DONE = 4; // readyState 4 means the request is done.
const OK = 200; // status 200 is a successful return.
if (xhr.readyState === DONE) {

Keybase proof

I hereby claim:

  • I am subramaniashiva on github.
  • I am sivasubramaniam (https://keybase.io/sivasubramaniam) on keybase.
  • I have a public key ASBszw8F6F-3mjN6KQ4un51ynnkfhyXfw1SyYDuO6xtvjAo

To claim this, I am signing this object:

@subramaniashiva
subramaniashiva / call_function_using_string
Created April 19, 2014 18:59
Call a javascript function using a string variable which contains the function name to be executed
/*jslint browser:true */
/*global console:true */
/*global window:true */
'use strict';
//The motive of the script is to execute a function using a string whose value is the function name
//printMe is a function that needs to be called when user passes the string "printMe"
var printMe = function (a, b) {
console.log(a, b);
};