I am calling a function in options variable to get data from an api but that function returns promise which is rejected while same function working fine when executed seperately
Please suggest some solution??
I am calling a function in options variable to get data from an api but that function returns promise which is rejected while same function working fine when executed seperately
Please suggest some solution??
const getSalutationId = () => {
var options1 = {
url: '',
method: 'GET',
headers: {
'Accept': 'application/json',
'X-EMAIL': ,
'X-PASSWORD': ,
'Authorization':
},
params: {
'email': ,
'password':
}
}
return z.request(options1)
.then((response1) => {
return response1.json;
}).then((response4) => {
// return response4.layoutItems[0].layoutItems[0].item.pickLists.filter(function(item) {
// return item.name == "MRS";
// });
return response4.layoutItems[0].layoutItems[0].item.pickLists.findOne({
where: {
name: "MRS"
}
})
})
.then((data_filter1) => {
return parseInt(JSON.stringify(data_filter1[0].id))
})
}
const options = {
url: '',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': ,
'X-EMAILS': ,
'X-SOURCE':
},
params: {
'password': ,
'emails':
},
body: {
'firstName': bundle.inputData.firstName,
'lastName': bundle.inputData.lastName,
'address': bundle.inputData.address,
'city': bundle.inputData.city,
'companyAddress': bundle.inputData.companyAddress,
'companyAnnualRevenue': bundle.inputData.companyAnnualRevenue,
'companyCity': bundle.inputData.companyCity,
'companyName': bundle.inputData.companyName,
'companyState': bundle.inputData.companyState,
'companyZipcode': bundle.inputData.companyZipcode,
'department': bundle.inputData.department,
'designation': bundle.inputData.designation,
'requirementBudget': bundle.inputData.requirementBudget,
'requirementName': bundle.inputData.requirementName,
'state': bundle.inputData.state,
'zipcode': bundle.inputData.zipcode,
'phoneNumbers': format_phoneNumber(),
'emails': format_emailId(),
'salutation': getSalutationId(),
'pipeline': bundle.inputData.pipeline,
'products': bundle.inputData.products,
'companyBusinessType': bundle.inputData.companyBusinessType,
'timezone': bundle.inputData.timezone,
'requirementCurrency': bundle.inputData.currency,
'country': bundle.inputData.country,
'companyCountry': bundle.inputData.companyCountry,
'companyIndustry': bundle.inputData.companyIndustry,
'campaign': bundle.inputData.campaign,
'source': bundle.inputData.sourceName,
'companyEmployees': bundle.inputData.companyEmployees
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = z.JSON.parse(response);
// // You can do any parsing you need for results here before returning them
return results;
});
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.