Angular 角度6 http响应问题

Angular 角度6 http响应问题,angular,http,get,Angular,Http,Get,我发现HttpClientget请求有一个非常奇怪的行为 答复1 API发送: { payload: { object: { array: [1, 2, 3] } } } { payload: { array: [ object: { array: [1, 2, 3] } ] } } 角度接收: { payload: { object: { array: []

我发现
HttpClient
get
请求有一个非常奇怪的行为

答复1 API发送:

{
  payload: {
    object: {
      array: [1, 2, 3]
    }
  }
}
{
  payload: {
    array: [
      object: {
        array: [1, 2, 3]
      }
    ]
  }
}
角度接收:

{
  payload: {
    object: {
      array: []
    }
  }
}
{
  payload: {
    array: [
      object: {
        array: [1, 2, 3]
      }
    ]
  }
}
答复2 API发送:

{
  payload: {
    object: {
      array: [1, 2, 3]
    }
  }
}
{
  payload: {
    array: [
      object: {
        array: [1, 2, 3]
      }
    ]
  }
}
角度接收:

{
  payload: {
    object: {
      array: []
    }
  }
}
{
  payload: {
    array: [
      object: {
        array: [1, 2, 3]
      }
    ]
  }
}
有人见过这种行为吗

更新 角度代码: API代码: 更新2 响应功能代码:

function sendResponse(response, status, message, payload) {
  return response
    .status(status)
    .send({
      status: status,
      message: message,
      payload: payload
    });
}

module.exports = {
  200: (res, result) => sendResponse(res, 200, 'SUCCESS', result),
  201: (res, result) => sendResponse(res, 201, 'CREATED', result),
  204: (res, result) => sendResponse(res, 201, 'UPDATED', result),
  205: (res, result) => sendResponse(res, 201, 'REMOVED', result),
  301: (res, result) => sendResponse(res, 301, 'REDIRECTED', result),
  400: (res, result) => sendResponse(res, 400, 'NOT_VALID', result),
  401: (res, result) => sendResponse(res, 401, 'NOT_AUTHENTICATED', result),
  403: (res, result) => sendResponse(res, 403, 'NOT_AUTHORIZED', result),
  404: (res, result) => sendResponse(res, 404, 'NOT_FOUND', result),
  406: (res, result) => sendResponse(res, 406, 'WRONG_TYPE', result),
  409: (res, result) => sendResponse(res, 409, 'DUPLICATE', result),
  501: (res, result) => sendResponse(res, 501, 'ELSE_SERVER', result)
};
更新3

这是因为异步行为,只需在调用结束前查看是否打印angular。

为什么要进行Facing非常奇怪,我从未有过这种行为。你能添加一些代码吗?@xrobert35我添加了代码背后有什么代码?utils of:utils。response@xrobert35我添加了响应函数的代码。顺便说一句,你在角度方面没有任何http拦截器吗?也许,我仔细检查了文档,什么都没有。如果订阅在获取整个信息之前被调用,仅仅是因为“异步行为”很多应用程序都会遇到麻烦:)这就是我所说的,为什么是否定标记。我真的不明白。在某些情况下,http客户端的订阅将在接收到所有信息时被调用,除非您正在执行多部分操作。这不是因为异步行为。如果在调用subscribe时,必须检查对象的每个部分是否都已加载,您将如何处理这些信息