Getting undefined response on customer create

I am trying to store some information on my backend when I create a user, the information is supposed to be the response from creating a customer, but I get undefined.
Here is my code.
import { json } from “express”;
//This class is used for creating customers on Dwolla.
var dwolla = require(‘dwolla-v2’);

var key = “0000”
var secret = “0000”
var client = new dwolla.Client({
// key: process.env.DWOLLA_APP_KEY,
// secret: process.env.DWOLLA_APP_SECRET,
environment: ‘sandbox’,

//RequestBody contains the information pertaining to the user.
var requestBody = {
firstName: firstName,
lastName: lastName,
email: email,
type: ‘personal’,
address1: address1,
city: city,
state: state,
postalCode: postalCode,
dateOfBirth: dateOfBirth,
// For the first attempt, only the
// last 4 digits of SSN required
// If the entire SSN is provided,
// it will still be accepted
ssn: ssn

async function asyncCall() {
try {
.then(appToken =>‘customers’, requestBody))
//‘customers’, requestBody)
.then(res => res.headers.get(‘location’)) // => ‘
// .then(res => console.log(res.headers.get(‘location’)))
.then(async function(res) {
const result = await (JSON.stringify(res.body));
const result2 = await (JSON.stringify(res.headers));

  } catch (err) {
    console.log("Did not work");


// expected output: 'resolved'


Hi @adoba - it looks like it may be due to promises chaining that you’re getting undefined on the second .then().

You could do something like the following for accessing the headers/body/status:

  .post("customers", {
    firstName: "Jane",
    lastName: "Doe",
    email: ""
    function(res) {
        const location = (JSON.stringify(res.headers.get("location")));
        // res.status  => 201
        // res.body     => Object or String depending on response type
    function(error) {
        // when the server return a status >= 400
        // error.status   => 400 
        // error.headers  => Headers { ... }
        // error.body     => Object or String depending on response type

It also looks like you may be using an older version of our Node SDK. I’d recommend checking out the latest version which comes with niceties, likeToken Management, baked in.

Hope that helps!

1 Like

Definitely did, awesome thanks!

1 Like