Created
July 9, 2014 21:56
-
-
Save jeremiak/a6e803640992a797e637 to your computer and use it in GitHub Desktop.
return the return of the return
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
var $ = require('jquery') | |
var Home = require('./models/home') | |
function homeFromJSON(json) { | |
var json = JSON.parse(json) | |
var data = { | |
id: json.id, | |
quote: 'string', | |
address: json.address, | |
type: 'string', | |
data: [], | |
owner: {} | |
} | |
var home = new Home(data) | |
console.log(home) | |
return home | |
} | |
var APIClient = function() { | |
var APIRoot = 'http://www.corsproxy.com/bestnest-api-dev.herokuapp.com/' | |
return { | |
fetch: function(endpoint) { | |
return $.ajax({ | |
url: APIRoot + endpoint | |
}) | |
}, | |
getHome: function(id, cb) { | |
return this.fetch('buildings/'+id) | |
.done(homeFromJSON) | |
}, | |
search: function(text, cb) { | |
console.log('Search currently not implemented, good luck finding', text) | |
} | |
} | |
} | |
module.exports = APIClient |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you could do something like