Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="can-fixture error demo">
<meta name="" content="" />
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<ul id='out'>Loading</ul>
  <script src='https://rawgit.com/canjs/can-fixture/v0.2.1/dist/global/can-fixture.js'></script>
  <script src="https://code.jquery.com/jquery-2.1.4.js"></script>
</body>
</html>
 
// fixture code ----------
fixture("GET /todos", function(req, response){
  response(401,{message: "Please login to see todos."})
});
// client code -----------
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function(){
  var response = JSON.parse(this.responseText);
  var lis = response.data.map(function(todo){
    return "<li>"+todo.name+"</li>"
  });
  var el = document.getElementById("out")
  el.innerHTML = lis.join("");
});
xhr.addEventListener('error', function(){
  var response = JSON.parse(this.responseText);
  var el = document.getElementById("out")
  el.innerHTML = response.message;
});
xhr.open('GET', "/todos");
xhr.send();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x