how can i use the promise method in node?

I think you need something like that :

const email = "[email protected]"
const request = require('request');
function isUserExists(email, kc_accessToken) {
    let url = `${path}/users?email=${email}`;

    return new Promise(function(resolve, reject){
            url: url,
            headers: {
                "content-type": "application/json",
                "authorization": `Bearer ${kc_accessToken}`
        }, function (error, response, body) {
            if (error) {
                console.log("some error occured");
            if ( > 0) {
                return resolve();

            return reject();


CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top