-
Notifications
You must be signed in to change notification settings - Fork 57
Description
Current State
Node Library has middleware that causes objects with an id to be stripped of any keys/values that are not id when making HTTP requests (or responding on an HTTP request).
Desired State
- [] As a developer, I want clarity on what information is being sent to EasyPost or to my other applications from my Node server (which has easypost-node middleware). I want my objects basically sent "as-is" with minimal modifications from middleware.
Impact
When sending data from my Node server to a front-end client, as an example, I've found that objects are being sent without all of the information that I may want to have access to on the front end. This is confusing because it is not easy for me to tell why this is happening.
Examples
I make a request to EasyPost to create a shipment and receive a response back with the full shipment object, including nested objects like from_address, to_address, parcel etc. These object include multiple keys such as name, company, street1 etc as well as a unique identifier created by easypost, such as adr_123456
When take that entire shipment object and send it to my front-end application, something weird happens
//from my node server, where response.data is the full response.data from EasyPost
res.send(response.data)
my front-end application logs the response from my server like so:
{
"id": "shp_123456",
"object": "Shipment",
"reference": "testing",
"mode": "test",
"created_at": "2022-03-09T20:53:14Z",
"updated_at": "2022-03-09T20:53:14Z",
"to_address": {
"id": "123456"
},
"from_address": {
"id": "123456"
},
"return_address": {
"id": "123456"
},
"buyer_address": {
"id": "123456"
},
"parcel": {
"id": "123456"
},
"carrier_accounts": [
"ca_123456"
],
"forms": [],
"rates": [
{
"id": "rate_123456",
"object": "Rate",
"created_at": "2022-03-09T20:53:14Z",
"updated_at": "2022-03-09T20:53:14Z",
"mode": "test",
"service": "Priority",
"carrier": "USPS",
"rate": "8.56",
"currency": "USD",
"retail_rate": "11.65",
"retail_currency": "USD",
"list_rate": "8.56",
"list_currency": "USD",
"delivery_days": 1,
"delivery_date": null,
"delivery_date_guaranteed": false,
"est_delivery_days": 1,
"shipment_id": "shp_123456",
"carrier_account_id": "ca_123456"
},
I'm expecting my objects to contain more information, such as:
"from_address": {
"id": "123456",
"name":"Guy Man",
"company":"Man and Guy Industries",
"street1":"123 fake street",
.....
Note how it doesn't do anything with rates[0] because rates is an array and not an object.
Steps to Reproduce the Issue
when using EasyPost node middleware, send an HTTP request/response with objects that contain an id as well as other key/value pairs. Then observe how they are received on the other end of the request.
Code
I believe the offending code is in this base.js file at https://github.com/EasyPost/easypost-node/blob/master/src/resources/base.js#L281