goshippo / shippo-node-client

Shipping API Node.js library (USPS, FedEx, UPS and more)
https://goshippo.com/docs
MIT License
136 stars 54 forks source link

ES6 Imports Don't Work #81

Open osseonews opened 2 years ago

osseonews commented 2 years ago

We are able to successfully use Require to use this library, but using imports doesn't work, and unfortunately our current set up requires imports.

Whenever we import, we get 400 response with "Invalid credentials". We know our credential are fine, as we use them daily in another app which uses require. how do you use this library with Imports?

Our code:

import * as Shippo from 'shippo'
const shippo = new Shippo.default('YOURSHIPPOID');
macder commented 2 years ago

This works for me

import shippo from "shippo"

shippo(SHIPPO_API_KEY).carrieraccount.list().then(r => console.log(r))

OR

import shippo from "shippo"

const client = shippo(SHIPPO_API_KEY)
client.carrieraccount.list().then(r => console.log(r))