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].layoutItemsp0].item.pickLists.findOne({
    where: {
     name: "MRS"
    }
   })
  })
  .then((data_filter1) => {
Â
   return parseInt(JSON.stringify(data_filter1t0].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;
Â
});
Just checking in to see if you still need help with this?Â
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.