返回结果
child {
Description: 'This is a wallet',
Owners: [ '62766708' ],
Balance: { Currency: 'GBP', Amount: 0 },
Currency: 'GBP',
FundsType: 'DEFAULT',
Id: '62766709',
Tag: null,
CreationDate: 1552916375 }
功能
let resultToUpdate;
if (userType == "natural") {
resultToUpdate = await createNaturalUser(
firstName,
lastName,
birthday,
nationality,
countryOfResidence,
email
);
setTimeout(() => {
console.log(resultToUpdate.child); // undefined
}, 1000);
}
如您所见,我什至尝试了setTimeout
编辑。这是createNaturalUser
函数,扩展到createUserWallet
。因此,上面的子对象是从第二个函数返回的
// ======================================================================
// CREATE NATURAL USER
// ======================================================================
export function createNaturalUser(
firstName,
lastName,
birthday,
nationality,
countryOfResidence,
email
) {
var result = new Date(birthday).getTime().toString();
var birthdayTimestamped = Number(result.slice(0, -3));
var naturalUser = new mangoPay.models.UserNatural({
FirstName: firstName, // First Name
LastName: lastName, // Last Name
Birthday: birthdayTimestamped, // timestamp
Nationality: nationality, //
CountryOfResidence: countryOfResidence, //
Email: email // User email
});
return mangoPay.Users.create(naturalUser).then(function(response) {
// Output the created user data to console
return createUserWallet(response.Id);
});
}
// ======================================================================
// CREATE USER WALLET
// ======================================================================
export function createUserWallet(owner) {
var userWallet = new mangoPay.models.Wallet({
Owners: [owner],
Description: "This is a wallet",
Currency: "GBP"
});
return mangoPay.Wallets.create(userWallet).then(function(response) {
// console.log(response);
return response;
});
}