Skip to content

Instantly share code, notes, and snippets.

@KameronKales
Created May 4, 2019 21:07
Show Gist options
  • Save KameronKales/740f5ade0128e534df81fdf83f056e51 to your computer and use it in GitHub Desktop.
Save KameronKales/740f5ade0128e534df81fdf83f056e51 to your computer and use it in GitHub Desktop.
Export in Chrome Extension to make http requests easy
function get_http (aURL, aCallback){
console.log(aURL)
var anHttpRequest = new XMLHttpRequest();
anHttpRequest.onreadystatechange = function(aCallback) {
if (anHttpRequest.readyState == 4 && anHttpRequest.status == 200)
aCallback(anHttpRequest.responseText);
}
anHttpRequest.open( "GET", aURL, true );
anHttpRequest.send( null );
}
module.exports = {
get_http
}
let http = require("./helpers/http_helper.js");
http.get_http('http://localhost:3000/test', function(resp) {
console.log(resp)
})
@user512
Copy link

user512 commented May 5, 2019

@KameronKales, try removing aCallback on line 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment