Closed radivojenovamedia closed 1 month ago
hmm, the fetch api should be available in the supported node versions (v18 and v20), can you confirm which version of node you're using?
I am using Node.js version 18.18.0. I tested the SDK without NestJS, and it worked correctly. However, when integrating it with the NestJS framework, the headers are not being recognized, despite the declaration for the Headers
class existing in the lib.d.ts
file.
@shippo-lueders I believe I have found the cause of the issue. It seems that the nestjs-fetch library was the problem. Once I removed it, the SDK started working correctly. My apologies for any inconvenience this may have caused.
ah, good to know. glad things are working for you now and thanks for letting us know the root cause!
Describe the bug: I'm encountering a Headers is not defined error when making any request using the Shippo Node.js SDK in a NestJS application.
To Reproduce: Steps to reproduce the behavior:
Expected behavior: The request should successfully create a shipment without errors.
Screenshot:![image](https://github.com/goshippo/shippo-javascript-sdk/assets/109510031/230c422f-8884-44fe-ba41-7665da854f3f)
`import { Controller, Post } from '@nestjs/common'; import { DistanceUnitEnum, Shippo, WeightUnitEnum } from 'shippo';
@Controller('shippo') export class ShippoController { shippo: Shippo; constructor() { this.shippo = new Shippo({ apiKeyHeader: 'shippo_test_shippo_token', shippoApiVersion: '2018-02-08', }); }
@Post('create') async createShipment() { const shipment = this.shippo.shipments.create({ addressFrom: { zip: '22191', country: 'Virginia', }, addressTo: { zip: '27359', country: 'North Carolina', }, parcels: [ { massUnit: WeightUnitEnum.Kg, weight: '3.3', width: '100', height: '100', length: '10', distanceUnit: DistanceUnitEnum.Cm, }, ], });
} }`