Invalid or unexpected token at new Function of Enumerable using linqjs - linq.js

I want to return an object using Enumerable of linqjs. But this code gives an error "Invalid or unexpected token". When I check the same condition using if condition in forEach then it is working perfectly. But what's problem with Enumerable?
Using Linqjs
var checkAddressForUpdate = Enumerable.From($scope.companyAddresslist).Where("$.Address === '" + $scope.ad_CompanyAddress.Address + "' && $.SlNo !== " + $scope.ad_CompanyAddress.SlNo).FirstOrDefault();
Using If Condition
var checkAddressForUpdate;
angular.forEach($scope.companyAddresslist, function (comAddress) {
if (comAddress.Address == $scope.ad_CompanyAddress.Address && comAddress.SlNo != $scope.ad_CompanyAddress.SlNo) {
checkAddressForUpdate = comAddress;
}
});
Error in console
enter image description here

Related

nodejs cookie-session typeerror

TypeError: this.keys.index is not a function
the console log show that the if condition line is error
app.get('/',(req,res)=>{
if(!req.session.authenticated){
res.redirect('/login');
}else{
res.redirect('/search')
}
})
it was fine until i start another server.js from a completely different folder. I have tried to reinstall the node_module to fix it but it just result the same. but the weird part is i can start the server in a vm without any problem. can any help me with this?
Cookies.prototype.get = function(name, opts) {
var sigName = name + ".sig"
, header, match, value, remote, data, index
, signed = opts && opts.signed !== undefined ? opts.signed : !!this.keys
header = this.request.headers["cookie"]
if (!header) return
match = header.match(getPattern(name))
if (!match) return
value = match[1]
if (!opts || !signed) return value
remote = this.get(sigName)
if (!remote) return
data = name + "=" + value
if (!this.keys) throw new Error('.keys required for signed cookies');
index = this.keys.index(data, remote)
if (index < 0) {
this.set(sigName, null, {path: "/", signed: false })
} else {
index && this.set(sigName, this.keys.sign(data), { signed: false })
return value
}
};
I realise that this answer is late in the day but might help someone with the same error. I was getting the error 'TypeError: this.keys.index is not a function' on line 73 of index.js in cookies when trying to use koa-session.
I eventually realised that I had set app.keys to a single value i.e.
app.keys = 'dieueyf7huienejnfef'
When it should be an array:
app.keys = ['dieueyf7huienejnfef']

Office.context.mailbox.item.addFileAttachmentAsync The code worked correctly. Why an internal error has occurred?

Previously the code worked correctly. Why an internal error has occurred?
Is this a problem with the JavaScript API for Office?
https://learn.microsoft.com/en-us/outlook/add-ins/add-and-remove-attachments-to-an-item-in-a-compose-form
The link and title are correct. I checked it out.
var options = {
asyncContext: null
};
Office.context.mailbox.item.addFileAttachmentAsync(link, title, options, function (asyncResult) {
console.log("asyncResult: " + JSON.stringify(asyncResult));
if (asyncResult.status === "succeeded") {
$docName.prepend("<i class='ms-Icon ms-Icon--checkbox ms-font-m ms-fontColor-green'>");
$fileProcess.resolve();
} else {
console.log("Office.context.mailbox.item.addFileAttachmentAsync() [" + asyncResult.status + "] error: "//
+ JSON.stringify(asyncResult.error) + " value: " + JSON.stringify(asyncResult.value));
$fileProcess.reject();
$attachedDoc.addClass("ms-bgColor-error");
$docName.prepend("<i class='ms-Icon ms-Icon--alert ms-font-m ms-fontColor-error'></i>");
$docName.after("<div class='ms-ListItem-tertiaryText addedError'>" + asyncResult.error.message + "</div>");
}
});
I got an asyncResult:
asyncResult: {"value":null,"status":"failed","error":{"name":"Internal Error","message":"An internal error has occurred."}}
The problem was with a self-signed certificate.

Firebase - Cloud Functions: enumerate [Object Object]

I would like to enumerate the members object from the below structure.
I do not have prior experience in node.js, I have tried the following code and it doesn't seem to work.
exports.sendVaultUnlockedPush = functions.database.ref('/Vaults/{id}/action').onUpdate(event => {
let status = event.data.val();
if (status == 'lock') {
var db = admin.database();
var vaultRef = db.ref("/Vaults/" + event.params.id);
vaultRef.once('value').then(function(snapshot) {
var hasMembers = snapshot.child('members');
if (hasMembers) {
var memberRef = db.ref("Vaults/" + event.params.id + "/members");
memberRef.once('value').then(function(memberSnapshot) {
memberSnapshot.forEach(function(element) {
console(element.key + " - " + element.val());
}, this);
});
}
});
}
})
It throws the following error:
Error: Firebase.DataSnapshot.forEach failed: Was called with 2 arguments. Expects no more than 1.
at Error (native)
at z (/user_code/node_modules/firebase-admin/lib/database/database.js:42:1666)
at T.forEach (/user_code/node_modules/firebase-admin/lib/database/database.js:114:179)
at /user_code/index.js:34:36
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
I would just like it to return the value of 'members' node. And I have no clue to do the same.
Any help is much appreciated in getting this sorted. Thanks!
According to the docs forEach takes only one parameter:
This should work:
var values;
memberSnapshot.forEach(function(element) {
console(element.key);
values = element.val();
for (var val in values) {
if (values.hasOwnProperty(val)) {
console(val, values[val]);
}
}
});
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in

SharePoint error movesiteTitle() when ever page loads following error come

ReferenceError: documentGetElementsByName is not defined
MoveSiteTitle();
ReferenceError: MoveSiteTitle is not defined
MoveSiteTitle();
Any help ....!
Well, seems to be a Chrome related issue as df1 reported. There is one solution however to get rid of the script error if you like.
Put this code inside your master page above the s4-workspace tag or similar:
if(typeof documentGetElementsByName==='undefined')
{
documentGetElementsByName = function(value){
if($('[name="'+value+'"]'))
{
return $('[name="'+value+'"]');
}
return null;
};
}
if(typeof MoveSiteTitle==='undefined')
{
// Well.... Don't know what this function is supposed to do
// but this way I am avoiding script error...
MoveSiteTitle = function(value){
return "";
};
}
This is just javascript basic error.Here documentGetElementsByName(What is the variable name here) Check this variable name and search cant find any where in ur current page. Modify variable name or put some condition over there.
The problem is that something in your configuration is causing the script that contains the method MoveSiteTitle() to not load.
I was able to obtain the source for the method "MoveSiteTitle" from my dev tools console. You could alter your master page to include the following JavaScript in the <head> section of the master page.
if (typeof MoveSiteTitle === 'undefined') {
function MoveSiteTitle() {
a:;
var b = documentGetElementsByName("titlewpTitleArea");
if (b == null || b[0] == null) return;
var a = b[0],
c = documentGetElementsByName("onetidProjectPropertyTitle");
if (c == null || c[0] == null) return;
var e = c[0],
d = document.getElementById("onetidPageTitleSeparator");
if (d == null) return;
if (Boolean(a.insertAdjacentElement)) {
a.insertAdjacentElement("afterBegin", d);
a.insertAdjacentElement("afterBegin", e)
} else {
a.insertBefore(d, a.firstChild);
a.insertBefore(e, a.firstChild)
}
}
}
Also, I found the MoveSiteTitle method (for Sharepoint 2013) in the following file within the hive (hive 15).
V:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\IE55UP.js
You might be able to debug your specific configuration from there.
Also, the script for GetElementsByName is...
function GetElementsByName(b) {
var a = document.getElementsByName(b);
if (a.length == 0 && Boolean(window.XMLHttpRequest)) a = FFGetElementsById(document, b);
return a
}

NodeJS : outputting a string using Express EJS Template

I have a code where on error I return a status with an error message:
if (err){
res.render('page1', {status:2, msg:'Server Error : Probable unable to connect'});
return;
}
In my page1.ejs, I have coded the following way:
var status = <%= status %>;
alert ( 'The status = ' + status);
if( status == 2)
{
var msg = "'" + <%= msg %> + "'";
alert(msg);
}
OR
if( status == 2)
{
alert('"' + <%= msg %> + "'");
}
I am trying to get the value of status and msg - but since 'msg' exists as multiple words I am not able to find a way to capture complete strings as passed from NodeJS. Firebug shows error as:
SyntaxError: missing ) after argument list
alert('"' + Server Error : Probable unable to connect+ "'");
-------------------|
Try this:
alert('<%= msg %>');
I am not an expert for EJS, but maybe this could work var msg = <%= msg %>; alert(msg);? Or simply alert(<%= msg %>)?

Resources