mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 11:07:29 +00:00
Decode Node's JSON response into arbitrary .NET type. Add VS stuff.
This commit is contained in:
@@ -14,15 +14,15 @@ var server = http.createServer(function(req, res) {
|
||||
if (!func) {
|
||||
throw new Error('The module "' + resolvedPath + '" has no export named "' + bodyJson.exportedFunctionName + '"');
|
||||
}
|
||||
|
||||
|
||||
var hasSentResult = false;
|
||||
var callback = function(errorValue, successValue) {
|
||||
if (!hasSentResult) {
|
||||
hasSentResult = true;
|
||||
if (errorValue) {
|
||||
res.status(500).send(errorValue);
|
||||
} else if (typeof successValue === 'object') {
|
||||
// Arbitrary object - JSON-serialize it
|
||||
} else if (typeof successValue !== 'string') {
|
||||
// Arbitrary object/number/etc - JSON-serialize it
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify(successValue));
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@ function invocationCallback(errorValue, successValue) {
|
||||
if (errorValue) {
|
||||
throw new Error('InputOutputStreamHost doesn\'t support errors. Got error: ' + errorValue.toString());
|
||||
} else {
|
||||
var serializedResult = typeof successValue === 'object' ? JSON.stringify(successValue) : successValue;
|
||||
var serializedResult = JSON.stringify(successValue);
|
||||
console.log(serializedResult);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user