i am getting "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://"myurl". (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 504" here is my API
createGroup(language, req, callback) {
let data = req.body;
if(req.file){
const csvFilePath = req.file.path;
var username=
csv()
.fromFile(csvFilePath)
.then((jsonObj) => {
var array1 = [];
for (let i = 0; i < jsonObj.length; i++) {
array1.push(jsonObj[i].phoneNumber);
}
UserCollection.find({ mobile: { $in: array1 } }, function (err, docs) {
if (err) {
console.log(err)
}
else {
// console.log(docs[0]._id);
var array2 = [];
for (let i = 0; i < docs.length; i++) {
array2.push(docs[i]._id.toString());
}
let groupObj = new Group({
groupName: data.groupName,
users: array2,
courses: [],
effectiveDate: data.effectiveDate,
effectiveStatus: data.effectiveStatus,
createdBy:ObjectId(req.id)
});
groupObj.save((error, result) => {
if (error) {
return callback(false, common.errorMsg("Went wrong"));
}
return callback(false, common.successMsg("GROUP CREATED", {}));
});
}
});
}
)
}else{
let groupObj = new Group({
groupName: data.groupName,
users: data.users, //.split(","),
courses: [],
effectiveDate: data.effectiveDate,
effectiveStatus: data.effectiveStatus,
createdBy:ObjectId(req.id)
});
groupObj.save((error, result) => {
if (error) {
console.log(error)
return callback(false, common.errorMsg("Went wrong"));
}
return callback(false, common.successMsg("GROUP CREATED", {}));
});
}
};
here is the post request i am sending from front end
groupName: testing users: 61937f894f95f04da73cc586 effectiveStatus: 1 effectiveDate: Fri Aug 19 2022 files: