GET请求到API请求的状态代码为502。如何解决此问题?

时间:2019-12-04 17:48:50

标签: https nestjs

我正在使用nestjs框架构建应用程序。我已经创建了控制器和服务来从Http端点获取数据。我没有得到json数据,而是在输出中得到了endpoint is working fine on Google Chromeimport { Injectable, HttpService } from '@nestjs/common'; import { map } from 'rxjs/operators'; @Injectable() export class MessageService { constructor(private readonly httpService: HttpService) {} configEndPoint: string = 'https://jsonplaceholder.typicode.com/todos/1'; getData(source: string, productCode: string, vehicleType: string) { return this.httpService .get(this.configEndPoint) .pipe(map(response => response.data.json())); } } 。我已将我的应用程序与Swagger UI集成在一起。我应该对代码进行哪些更改,以便可以从端点获取数据?

这是我的服务。

import { Controller, Post, Body, Get } from '@nestjs/common';
import {
  ApiImplicitHeader,
  ApiOperation,
  ApiResponse,
  ApiUseTags,
} from '@nestjs/swagger';
import { ProductEvent } from '../dto/product-event';
import { MessageService } from '../service/message/message-service';

@Controller('/service/api/message')
export class MessageController {
  source: string;
  productCode: string;
  vehicleType: string;
  constructor(private messageService: MessageService) {}

  @Post()
  @ApiUseTags('processor-dispatcher')
  @ApiOperation({ title: 'Generate product message for the SNS topics' })
  async generateMessage(@Body() productEvent: ProductEvent) {


    return JSON.stringify(
      this.messageService.getData(
        this.source,
        this.productCode,
        this.vehicleType,
      ),
    );
  }
}

这是我的控制器。

String solrServerUrl = "https://<IP Address>:<portNo>/solr/Subscriptions";//enter actual IP address and port
SolrClient client = new HttpSolrClient.Builder(solrServerUrl ).build();

0 个答案:

没有答案