I am calling one API "getProjectListForInstance" and getting result in response which is an array of objects. Like this :
[ { "_id": "uyuyiuyiuy", "project_name": "Project1", }, { "_id": "hjhjhjhjkh", "project_name": "Project2", } ]
return new Promise((resolve, reject) => {
RESTService.getProjectListForInstance(previousInstance)
.then((result) => {
this.copyProjectInfo(result);
});
});
Now using above result in below code.
copyProjectInfo(projects) {
console.log('copyProjectInfo');
return new Promise((resolve, reject) => {
RESTService.createProjectInfoForNewInstance(projects)
.then((result) => {
console.log("Successfully done");
console.log(result);
});
});
},
The above code is not working. Getting 502 but when I am creating an array in code itself like below, then it is working fine.
copyProjectInfo(projects) {
console.log('copyProjectInfo');
let details =
[
{
"_id": "uyuyiuyiuy",
"project_name": "Project1",
},
{
"_id": "hjhjhjhjkh",
"project_name": "Project2",
}
];
return new Promise((resolve, reject) => {
RESTService.createProjectInfoForNewInstance(details)
.then((result) => {
console.log("Successfully done");
console.log(result);
});
});
},
Do I need to cast the Object received from first API before using it as an input for second API? and How?
Thanks, Jyoti