Using Superagent in your Browser

Quick tip.

I love superagent. Its a great lightweight JS httpclient that I use in almost all of my node apps that needs one.

But what if you want to use it in your browser frontend and you don’t know how?

All it takes:

Add the Javascript
<script src="https://cdnjs.cloudflare.com/ajax/libs/superagent/1.2.0/superagent.min.js"></script>
Call it!
<script>
superagent
  .get('/')
  .end(function(err,res){
     // do everything you want to res
   })
</script>

Thats it! No need to declare anything. just call superagent.