Authored by htoooth

add logger

... ... @@ -4,7 +4,11 @@ import apiUrl from '../../../../config/api-domain'
const request = require('axios');
function getBrand(shopId) {
return request.get(apiUrl.brand, {shopsId:shopId})
return request.get(apiUrl.brand, {
params: {
shopsId:shopId
}
})
}
function getCategory(shopId, brandId, level , sortId) {
... ... @@ -18,7 +22,9 @@ function getCategory(shopId, brandId, level , sortId) {
Object.assign(opts, {sortId});
}
return request.get(apiUrl.category, opts);
return request.get(apiUrl.category, {
params: opts
});
}
export default {
... ...
... ... @@ -30,11 +30,11 @@ module.exports = (req, res, next) => {
let allowApi = allowed(req.path);
if (!allowApi) {
logger.warn(`proxy ${req.method} fail`, `${req.path} can't find proxy url`);
logger.error(`proxy [${req.method}] fail`, `${req.path} can't find proxy url`);
return next();
}
logger.info(`proxy ${req.method} successful ok`, `[${req.path}] => [${allowApi[1].url}]`);
logger.info(`proxy [${req.method}] successful ok`, `[${req.path}] => [${allowApi[1].url}]`);
if (req.method.toLowerCase() === 'get') {
return api.get(allowApi[1].url, req.query).then(data => {
... ...