Created
October 31, 2012 11:36
-
-
Save nakamura-to/3986585 to your computer and use it in GitHub Desktop.
Concept code of WinJS.xhr Wrapper
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 xhr = new Xhr({ | |
baseUrl: 'http://localhost:8080/api', | |
user: "", | |
password: "", | |
type: 'json', | |
preHandler: function () {}, | |
postHandler: function () {}, | |
errorHandler, function () {} | |
headers: {}, | |
data: {}, | |
acceptStatus: [200] | |
}); | |
function getAaa(code) { | |
return xhr.get({ url: '/aaa/bbb', data: {code: code}, headers: {}, acceptStatus: [] }).then(Xhr.toJSON); | |
} | |
function deleteBbb(id) { | |
return xhr.del({ url: '/aaa/bbb', data: {id: id}, headers: {}, acceptStatus: [] }).then(Xhr.toJSON); | |
} |
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 Xhr(options) { | |
... | |
} | |
Xhr.toJSON = function (result) { | |
return JSON.parse(result.response); | |
} | |
Xhr.prototype.get = function (options) { | |
... | |
} | |
Xhr.prototype.post = function (options) { | |
... | |
} | |
Xhr.prototype.put = function (options) { | |
... | |
} | |
Xhr.prototype.del = function (options) { | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment