我有一个 api 一个域和其他域中的所有其他 api。
所以在 SprtsAppConstatnts.js 中,我对所有域进行了硬编码。
当我打印然后 formatUrl ---> 存在于 document.js 它打印哪个是正确的域然后 formatUrl ---> http://players.com/run/kit/?id=0900000000009009093292390230923
其中 URL ===> 在文件 SportsResUtility.js 中打印出错误的域 URL ===> http://sports.com/tes/run/kit/?id=090000000009009093292390230923
因为它exports.DATA_DNS_NAME = "http://sports.com";
从文件 SprtsAppConstatnts.js 中获取硬编码值
不确定如何在 SportsResUtility.js 中添加代码,以便仅针对此路径添加此域http://players.com
我在服务器日志中显示了两个错误。不确定它来自哪个文件。 (node:30332) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Can't set headers after they are sent.
(node:30332) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
有什么方法可以找出它来自哪个文件。我是否需要安装任何其他软件包进行调试。
在下面提供我的代码片段和沙箱
SprtsAppConstatnts.js
exports.GET_JWT_TOKEN_URL = 'https://credentials.com';
exports.DATA_DNS_NAME_CONTENT_CENTRAL = "http://players.com";
// "http://usersports.com"; // "http://fddfdfdf.main.com:9080"; // dp-rest-apis-url
exports.DATA_DNS_NAME = "http://sports.com"; // "http://fddfdfdf.main.com:9080"; // dp-rest-apis-url
exports.CUST_MICRO_SVC_DNS_NAME = "http://fddfdfdf.main.com";
exports.SERVICE_SERVER_DNS_NAME = 'http://sports.com';
exports.REST_API_dfdfdfdf_DNS_NAME = 'https://dfdfdfdf.com';
SportsResUtility.js
const axios = require('axios');
const SprtsAppConstatnts = require('../../constants/SprtsAppConstatnts');
const credentials = require('../../internals/credentials.json');
const authUtil = require('./AuthorizationUtil');
module.exports =
{
callService : (res, url, uri) => {
var formatUrl;
if(uri){
formatUrl = uri + url;
}
else{
formatUrl = SprtsAppConstatnts.DATA_DNS_NAME + url;
}
九州编程
相关分类