Created
May 4, 2019 21:07
-
-
Save KameronKales/740f5ade0128e534df81fdf83f056e51 to your computer and use it in GitHub Desktop.
Export in Chrome Extension to make http requests easy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let http = require("./helpers/http_helper.js"); | |
http.get_http('http://localhost:3000/test', function(resp) { | |
console.log(resp) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@KameronKales, try removing
aCallback
on line 4