2016-05-11 11:53:28 +00:00
|
|
|
// Copyright IBM Corp. 2016. All Rights Reserved.
|
|
|
|
// Node module: strong-error-handler
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2019-10-11 13:57:15 +00:00
|
|
|
const safeStringify = require('fast-safe-stringify');
|
2019-09-03 21:24:40 +00:00
|
|
|
|
2016-05-11 11:53:28 +00:00
|
|
|
module.exports = function sendJson(res, data) {
|
2019-10-11 13:57:15 +00:00
|
|
|
const content = safeStringify({error: data});
|
2016-05-11 11:53:28 +00:00
|
|
|
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
|
|
res.end(content, 'utf-8');
|
|
|
|
};
|