export function getCustomers ( ) { let promise = new Promise ( function ( resolve , reject ) { console . log ( "Getting customers" ) ; setTimeout ( function ( ) { let success = true ; if ( success ) { resolve ( "John Smith" ) ; } else { reject ( "Can't get customers" ) ; } } , 1000 ) ; } ) ; return promise ; } function getOrders ( customer ) { let promise = new Promise ( function ( resolve , reject ) { setTimeout ( function ( ) { let success = true ; if ( success ) { resolve ( `Found the order 123 for ${ customer }` ) ; } else { reject ( "Can't get orders" ) ; } } , 1000 ) ; } ) ; return promise ; } getCustomers ( ) . then ( ( cust ) => { console . log ( "Got customer" + cust ) ; return cust ; } ) . then ( ( cust ) => getOrders ( cust ) ) . then ( ( order ) => console . log ( order ) ) . catch ( ( err ) => console . error ( err ) ) ; console . log ( "This is the last line in the code. Chained getCustomers() and getOrders()." ) ;