close

[Solved] “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query Error Occurs?

Today I get the following error “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query in javascript.

How To Solve “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query Error ?

  1. How To Solve “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query Error ?

    To Solve “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query Error I've had this error when my ajax call returned malformated JSON

  2. “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query

    To Solve “Uncaught (in promise) undefined” error when using with=location in Facebook Graph API query Error I've had this error when my ajax call returned malformated JSON

Solution 1

The reject actually takes one parameter: that’s the exception that occurred in your code that caused the promise to be rejected. So, when you call reject() the exception value is undefined, hence the “undefined” part in the error that you get.

You do not show the code that uses the promise, but I reckon it is something like this:

var promise = doSth();
promise.then(function() { doSthHere(); });

Try adding an empty failure call, like this:

promise.then(function() { doSthHere(); }, function() {});

This will prevent the error to appear.

However, I would consider calling reject only in case of an actual error, and also… having empty exception handlers isn’t the best programming practice.

Solution 2

I’ve had this error when my ajax call returned malformated JSON

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment