kndt84 / aws-api-gateway-client

A client module of AWS API gateway both for Node.js and browsers

Home Page:https://www.npmjs.com/package/aws-api-gateway-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import with Weback

dreams-and-thoughts opened this issue · comments

Are there any known issues with importing this using Webpack?

import { apigClientFactory } from 'aws-api-gateway-client'

This builds ok, but returns:

TypeError: Cannot read property 'newClient' of undefined

When I try the following:

var apigClient = apigClientFactory.newClient({

What am I doing wrong here?

edit:

This syntax works ok:

var awsApiGatewayClient = require('aws-api-gateway-client')
var apigClient = awsApiGatewayClient.newClient({

This module is developed for Node.js server side applications not for browser side ones. So webpack is not supported. I think it would be better to use official JavaScript SDK.
http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-generate-sdk-javascript.html

Actually seems to be working pretty well in the browser. Is there any reason not to use this?

I prefer this over the specific generated SDK from the API.

IMO it should work ok - webpack should bundle all the dependencies out for the browser fine.

also for the import vs require syntax above, did you try the "default" export/import?

import apigClientFactory from 'aws-api-gateway-client'

New version may work correctly, so I close this issue. If it does not work, please open a new issue.