首页 > 解决方案 > 使用节点 js 和 graphql 使用运营商代码过滤 amadeus 航班优惠

问题描述

我必须使用过滤 flightOfferorigin, destination, departureDate, carrier

但是在将运营商添加到参数时出现此错误消息 Some of the parameters were not recognized. Please check your query. 如何通过将运营商传递给 amadeus 查询来过滤结果?

查询

import * as Sentry from '@sentry/node';
import amadeus from './../../../../amadeus';

export default async (parent, args, context, info) => {
  try {
    const { result } = await amadeus.shopping.flightOffers.get({
      origin: args.filter.origin,
      destination: args.filter.destination,
      departureDate: args.filter.departureDate,
      carrier: args.filter.carrier
    });
    context.dictionaries =await result.dictionaries;
    return result.data;
  } catch (error) {
    console.log(error);
    Sentry.captureException(error);
    return [];
  }
};

标签: node.jsapollo-serveramadeus

解决方案


通过查看您的代码,不清楚您使用的是Flight Low-fare Search API还是Flight Offers Search API

在任何情况下,这 2 个 API 都没有运营商参数。如果要按航空公司过滤,可以使用:

航班低价搜索:

  • includeAirlines:要包含的航空公司 IATA 代码列表,以逗号分隔
  • excludeAirlines:要排除的航空公司 IATA 代码列表,以逗号分隔

航班优惠搜索:

  • IncludedAirlineCodes:要包含的航空公司 IATA 代码列表,以逗号分隔
  • excludeAirlineCodes:要排除的航空公司 IATA 代码列表,以逗号分隔

推荐阅读