on 12-11-2020 9:59 AM
Hi, experts,
We are using emit event to act as asynchronous request for data bulkcreate.
But it turns out synchronous.
Can you help me with it ?
the response 'accepted' was not returned until the emit process 'processBasicInfoEvent' was completely done.
Code snippets:
srv.on('EmployeeBasicInfoImport', async (request) => {
return 'accepted';
});
srv.after('EmployeeBasicInfoImport', async (data, request) => {
var batchImportData = request.data;
srv.emit('processBasicInfoEvent', batchImportData);
});
srv.on('processBasicInfoEvent', async (request) => {
const sfsrv = await cds.connect.to('successfactors');
var batchImportData = JSON.parse(JSON.stringify(request.data));
var logID = batchImportData.logID;
batchImportData = batchImportData.employees;
for (var employee of batchImportData) {
await process(employee, sfsrv);
}
processBasicInfologs(logID, batchImportData, 'processBasicInfoEvent');
return batchImportData;
});<br>
I assume it is sync because you use the "await" keyword. Try to return a promise instead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
11 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.