While accessing to Parse.Config at hosted-code startup (parse deploy) I get this stacktrace:
TypeError: Object #<Object> has no method 'request'
at Object.Parse._ajax (<anonymous>:654:17)
at null.<anonymous> (Parse.js:1:18442)
at e (Parse.js:2:8941)
at Parse.js:2:9694
at g (Parse.js:2:9431)
at c.extend.then (Parse.js:2:9679)
at Object.b._request (Parse.js:1:18277)
at Function.b.Config.get (Parse.js:1:24017)
at main.js:2:14
the code (in cloud/main.js) is:
Parse.initialize(applicationid,javascriptkey);
Parse.Config.get().then(
function (_config){
config = _config;
console.log('Configuration init completed');
}, function (_error){
console.log('Failed loading configuration');
});
// status function
Parse.Cloud.define("status", function(request, response) {
response.success("spike#digitalx tracker up and running!");
});
seems that Config.get is trying to invoke "request" on any object.
Thank you in advance
Related
I am trying to write a jest test for the xml2js parse.parseString, but when I pass in an invalid xml it just bypasses the parse.parseString function rather than return the error in the callback function. I want to trigger the error in the callback function.
import xml2js from 'xml2js';
const parser = new xml2js.Parser({
async: false
});
parser.parseString(`<_>&%xstest</_>`, (err, result) => {
if (err) {
console.log('error',err)
throw new Error(`Parser error: ${err}`);
}
console.log('result', result)
});
any idea on why I can not trigger the err in the callback of parse.parseString to call? I am unable to get parse.parseString to throw an error.
I'm getting an unhandled promise rejection error when I use useMutation with react native. Here's the code producing the issue:
const [createUser, { error, loading }] = useMutation(CREATE_USER_MUTATION);
Anytime my graphql server returns an error to the client I get an unhandled promise rejection error (screenshot below). I'm able to make it go away by adding an error handler like so, but it seems like a hack. Any thoughts? Am I doing something wrong or is this something that should be addressed by the apollo folks?
const [createUser, { error, loading }] = useMutation(CREATE_USER_MUTATION, {
onError: () => {}
});
Your createUser mutation is a promise you should handle error inside try catch block, or in upper scope inside apollo-link-error onError method.
const [createUser, { data, loading }] = useMutation(CREATE_USER_MUTATION, {
onError: (err) => {
setError(err);
}
});
With this we can access data with loading and proper error handling.
using Msal v1.0.2, loginPopup is not working from iFrame.
trying to get the UserAgentApplication instance using client_id. its throwing an exception:
TypeError: this.isCallback is not a function
at Object.UserAgentApplication (UserAgentApplication.ts:228)
const myMSALObj = Msal.UserAgentApplication(msalConfig);
myMSALObj.loginPopup(["user.read"]).then(function (loginResponse) {
return myMSALObj.acquireTokenSilent(accessTokenRequest);
}).then(function (accessTokenResponse) {
const token = accessTokenResponse.accessToken;
}).catch(function (error) {
//handle error
});
sample from . 'Quickstart for MSAL JS' works fine but when I try to integrate Msal inside iFrame of my JavaScript plugin code, its not working.
working code from sample:
var myMSALObj = new Msal.UserAgentApplication(msalConfig);
myMSALObj.handleRedirectCallback(authRedirectCallBack);
myMSALObj.loginPopup(requestObj).then(function (loginResponse) {
acquireTokenPopupAndCallMSGraph();
}).catch(function (error) {
//Please check the console for errors
console.log(error);
});
there was a typo causing this exception: TypeError: this.isCallback is not a function at Object.UserAgentApplication (UserAgentApplication.ts:228)
fix: const myMSALObj = new Msal.UserAgentApplication(msalConfig);
That should solve this exception issue.
I would like to read a collection in mLab(mongoDB) and get result document based on the request from AWS LAMBDA function.
I could write a nodeJS function code snippet and whatever timeout I set it results in
Task timed out after *** seconds
Any solution, link or thoughts will be helpful. Either JAVA or NODE
'use strict';
const MongoClient = require('mongodb').MongoClient;
exports.handler = (event, context, callback) => {
console.log('=> connect to database');
MongoClient.connect('mongodb://test:test123#ds.xyx.fleet.mlab.com:1234', function (err, client) {
if (err) {
console.log("ERR ",err );
throw err;
}
var db = client.db('user');
db.collection('sessions').findOne({}, function (findErr, result) {
if (findErr){
console.log("findErr ",findErr);
throw findErr;
} else {
console.log("#",result);
console.log("##",result.name);
context.succeed(result);
}
client.close();
});
});
};
P.S : Referred all related stack questions.
Lambda function returned success after adding db name in
MongoClient.connect('mongodb://test:test123#ds.xyx.fleet.mlab.com:1234/dbNAME')
Apart from declaring db name in
var db = client.db('dbNAME');
It should also be added in mLab connection URI.
I have an afterSave method that takes the authData from a user signing up with Facebook and retrieves his friends. This has been working fine until I later defined a beforeSave method on the User, the authData was no longer present in the afterSave method. Example code below:
Parse.Cloud.beforeSave(Parse.User, function (request, response){
response.success();
});
Even though that method doesn't do anything, it prevents authData from being present in the afterSave from the same chain:
Parse.Cloud.afterSave(Parse.User, function(request) {
Parse.Cloud.useMasterKey();
var user = request.object;
user.fetch();
if (!user.existed()) {
Parse.Cloud.httpRequest({
url:'https://graph.facebook.com/me/friends?access_token='+user.get('authData').facebook.access_token,
success:function(httpResponse){
// process user friends
},
error:function(httpResponse){
console.error(httpResponse);
}
});
}
});
i have used
Parse.Cloud.useMasterKey();
and
user.fetch();
still got the following error in the log
Result: TypeError: Cannot read property 'facebook' of undefined
Please be careful as fetch() is an async call, so should be chained:
user.fetch().then(function (user) {
// now have access to updated user
});
In your code your fetch will have no effect on the code after it, since you're not waiting for it to finish.