- Я выполняю прокси узла для моих вызовов API.
- на сервере узла. Я успешно могу подключиться к API и получить ответ.
- где на стороне клиента, когдаЯ не усматриваю URL-адрес, который я получаю ниже Ошибка
filePresentData response----> Promise {<pending>}
- , где, как при жестком коде, я получаю приведенную ниже ошибку.
filePresentData error----> Error: Network Error
at createError (createError.js:16)
at XMLHttpRequest.handleError (xhr.js:87)
- Я отладил с помощью консолей.
- , но все еще не увенчался успехом.
- предоставил мои журналы, код на стороне сервера и клиента ниже.
- canВы говорите мне, как это исправить.
action.js
функция экспорта filePresentData () {
console.log(" filePresentData----> ");
var jumpSearch = 'gr';
var searchVal = jumpSearch;
var searchMode = 'smart';
//we are using this replace method to hack the name search Mode
jumpSearch = jumpSearch.replace('/', '%2F');
jumpSearch = jumpSearch.replace('#', '%23');
jumpSearch = jumpSearch.replace('+', '%2B');
jumpSearch = jumpSearch.replace('.', '%2E');
jumpSearch = jumpSearch.replace(/'|-/g, "");
jumpSearch = jumpSearch.replace(/ /g, "%20");
let environment = globalConfig.getConfig('environment');
searchVal = searchVal.replace(/'|-/g, "");
var url = `/hjhjhj/swim/${searchMode}/${jumpSearch}`;
console.log(" fetchjumpData Url---> ", url);
if (environment !== "local") {
url = `/hjhjhj/swim/${searchMode}/${searchVal}`;
console.log(" inside if fetchjumpData Url---> ", url);
}
console.log(" Url----> ", url, searchMode, searchVal, jumpSearch);
return (dispatch) => {
var response;
response = axios.get(url);
//response = axios.get('http://world.com/jkjk/dffddfkldfkldlf/?id=rwekleklerklklerklerk');
console.log(" filePresentData response----> ", response);
response.then((result) => {
console.log(" filePresentData result----> ", result);
if (result) {
dispatch(fetchDataSuccess(result));
}
}).catch((error) => {
console.log(" filePresentData error----> ", error);
dispatch(setSearchError(error));
});
};
}
ошибка для сценария 1
filePresentData---->
SearchBoxAction.js:214 fetchjumpData Url---> /hjhjhj/swim/smart/gr
SearchBoxAction.js:217 inside if fetchjumpData Url---> /hjhjhj/swim/smart/gr
SearchBoxAction.js:219 Url----> /hjhjhj/swim/smart/gr smart gr gr
SearchBoxAction.js:226 filePresentData response----> Promise {<pending>}
SearchBoxAction.js:235 filePresentData error----> Error: Network Error
at createError (createError.js:16)
at XMLHttpRequest.handleError (xhr.js:87)
Request URL: http://world.com/jkjk/dffddfkldfkldlf/?id=rwekleklerklklerklerk
Request Method: GET
Status Code: 401 Unauthorized
ошибка для сценария 2
filePresentData---->
SearchBoxAction.js:214 fetchjumpData Url---> /hjhjhj/swim/smart/gr
SearchBoxAction.js:217 inside if fetchjumpData Url---> /hjhjhj/swim/smart/gr
SearchBoxAction.js:219 Url----> /hjhjhj/swim/smart/gr smart gr gr
SearchBoxAction.js:226 filePresentData response----> Promise {<pending>}
filePresentData result ----> {data: {…},status: 200, statusText: «OK», заголовки: {…}, config: {…},…} SearchBoxAction.js: 235 ошибка filePresentData ----> TypeError: networksData.slice не является функцией
файл сервера
const express = require('express');
const axios = require('axios');
const mime = require('mime-types');
const router = express.Router();
const ResponseUtil = require('../../utils/ResponseUtil');
const AppConstants = require('../../../constants/AppConstants');
const credentials = require('../../../internals/credentials.json');
const memberGroupingHelper = require('../../helpers/pcp/memberGrouping');
const exportHelper = require('../../helpers/pcp/pcpExportHelper');
const formatExportData = require('../../helpers/pcp/formatExportData');
const pcpCommonHelper = require('../../helpers/pcp/pcpCommonHelper');
const pcpProvDataHelper = require('../../helpers/group/getProvData');
//const aggregateHelper = require('../../helpers/group/aggregateFilter');
const {
PcpAggregatejumpsApi
} = require('psv-svc-utils');
router.get('/:searchMode/:jumpSearch', (req, res, next) => {
// router.get('/ecmstest', (req, res, next) => {
const {
originalUrl
} = req;
//console.log(" originalUrl ", originalUrl);
const mode = req.params.searchMode;
const value = encodeURIComponent(req.params.jumpSearch);
// const url = `/wewewe/weiopewopewopop/jumps?mode=${mode}&value=${value}`;
console.log("document 40--->", mode);
console.log("for document Testing0--->", mode);
// const url = `http://world.com/jkjk/dffddfkldfkldlf/?id=rwekleklerklklerklerk`;
const url = `/tes/weiopewopewopop/ecmsdocuments/?id=rwekleklerklklerklerk`;
console.log("AppConstants.GET_JWT_TOKEN_URL--->", AppConstants.GET_JWT_TOKEN_URL);
var formatUrl = AppConstants.wewewewewe_CONTENT_CENTRAL + url;
axios.get(AppConstants.GET_JWT_TOKEN_URL, {
auth: {
username: credentials.auth.racfId,
password: credentials.auth.password
}
})
.then((jwtResponse) => {
console.log("jwt then----->", jwtResponse.data.jwt);
console.log('then formatUrl --->', formatUrl);
// Return the promise from get so it is applied to the promise chain
return axios.get(formatUrl, {
headers: {
"Authorization": `Bearer ${jwtResponse.data.jwt}`,
"Content-Type": 'application/json'
}
})
.then((response) => {
// try {
console.log("document suceess then0--->");
const file = Buffer.from(response.data.content, 'base64');
const fileType = mime.contentType(response.data.contentInfo.fileType);
const fileExtension = response.data.contentInfo.fileType.toLowerCase();
const fileName = `filename=${response.data.contentInfo.id}.${fileExtension}`;
console.log("document suceess fileName--->", fileName);
return ResponseUtil.callService(res, url);
})
.catch((e) => {
// Catch any error that occurred in the promise chain...
if (e.response) {
return res.status(e.response.status).send(e.response.data);
}
return res.status(500).send(e.message || 'Something wrong');
});
});
// ResponseUtil.callService(res, url);
});
module.exports = router;
журналы сервера
controllers---> [ 'C:/codebase/fddfdf/server/controllers/root.js' ]
server is listening on 1010
callService ===> /hjhjhj/swim/i8cx/userimages
URL ===> http://veg/hjhjhj//i8cx/userimages
searchMode value---> gr
searchMode 3---> Smart
for document Testing---> Smart
callService ===> /hjhjhj/swim?mode=Smart&value=gr
URL ===> http://veg/hjhjhj/?mode=Smart&value=gr
callService ===> /hjhjhj/swim/=-wewewewe/erjkerjkerjkjker?history=false
URL ===> http://veg/hjhjhj//=-wewewewe/erjkerjkerjkjker?history=false
callService ===> /hjhjhj/swim/edfdfdf/erjkerjkerjkjker?history=false
URL ===> http://veg/hjhjhj//edfdfdf/erjkerjkerjkjker?history=false
callService ===> /hjhjhj/swim/wewewewe/erjkerjkerjkjker?history=false
URL ===> http://veg/hjhjhj//wewewewe/erjkerjkerjkjker?history=false
callService ===> /hjhjhj/swim/dew/erjkerjkerjkjker?history=false
URL ===> http://veg/hjhjhj//dew/erjkerjkerjkjker?history=false
callService ===> /hjhjhj/swim/wewewewe/erjkerjkerjkjker?history=false
URL ===> http://veg/hjhjhj//wewewewe/erjkerjkerjkjker?history=false
document 40---> smart
for document Testing0---> smart
AppConstants.GET_JWT_TOKEN_URL---> https://ererll;l;/erklklk
then formatUrl ---> http://world.com/jkjk/dffddfkldfkldlf/?id=rwekleklerklklerklerk
document suceess then0--->
document suceess fileName---> filename=a2c93187-5422-46c7-bcf7-e663c28dcd2e.pdf
callService ===> /jkjk/dffddfkldfkldlf/?id=rwekleklerklklerklerk
else if responseutil.jsURL ===> http://world.com/jkjk/dffddfkldfkldlf/?id=rwekleklerklklerklerk
URL ===> http://world.com/jkjk/dffddfkldfkldlf/?id=rwekleklerklklerklerk
callService ===> /hjhjhj/swim/i8cx/userimages
URL ===> http://veg/hjhjhj//i8cx/userimages