Dann ist nicht eine Funktion Versprechen Fehler

Ich bin neu verspricht und ich benutze den bluebird docs, um Daten aus asynchronen code

was ich versucht habe ist Folgendes:

der Fehler ist:

getToken.then ist nicht eine Funktion

Wie kann ich es vermeiden?

Diese Datei connection.js

return connection.getToken.then(function(connToken){

   console.log(connToken);

}).catch({


})

Dieser den code von getToken in moduleB

const request = require("request-promise");
const Promise = require("bluebird");
module.exports = {


    getToken: function () {


        return new Promise((resolve, reject) => {
            let options = {
                method: 'POST',
                url: 'https://authentication.arc.com/oauth/token',
                headers: {
                    grant_type: 'client_credentials',
                    authorization: 'Q0MDdmMCFiMTc0fGNvlQVRDWThDNDFsdkhibGNTbz0=',
                    accept: 'application/json;charset=utf-8',
                    'content-type': 'application/x-www-form-urlencoded'
                },
                form: {
                    grant_type: 'client_credentials',
                    token_format: 'opaque&response_type=token'
                }
            };


            request(options)
                .then(function (body) {

                    return body;
                })
                .catch(function (err) {
                    return err;          
                });
        })

    }
}
InformationsquelleAutor Jenny Hilton | 2017-07-05
Schreibe einen Kommentar