Skip to main content
Commonmark migration
Source Link

I have never used RSVP, I am more familiar with [Q][1]Q, but I believe following should do what you need:

var evaluate = function (xmlDoc) {
    TokenData = xmlDoc.evaluate(
        '/root/theToken',
    xmlDoc.documentElement,
    null,
    XPathResult.FIRST_ORDERED_NODE_TYPE,
    null).singleNodeValue.textContent;
    return TokenData;
}

RSVP.resolve(TokenData || LoadURIPromise(TokenURL).then(evaluate))
    .then(function (token) {
    //Use Token here
    console.info(token);
});

Here is working [jsFiddle][2]jsFiddle

BTW, do you really need TokenData to be global? [1]: https://github.com/kriskowal/q [2]: http://jsfiddle.net/tomalec/EsRkp/2/

I have never used RSVP, I am more familiar with [Q][1], but I believe following should do what you need:

var evaluate = function (xmlDoc) {
    TokenData = xmlDoc.evaluate(
        '/root/theToken',
    xmlDoc.documentElement,
    null,
    XPathResult.FIRST_ORDERED_NODE_TYPE,
    null).singleNodeValue.textContent;
    return TokenData;
}

RSVP.resolve(TokenData || LoadURIPromise(TokenURL).then(evaluate))
    .then(function (token) {
    //Use Token here
    console.info(token);
});

Here is working [jsFiddle][2]

BTW, do you really need TokenData to be global? [1]: https://github.com/kriskowal/q [2]: http://jsfiddle.net/tomalec/EsRkp/2/

I have never used RSVP, I am more familiar with Q, but I believe following should do what you need:

var evaluate = function (xmlDoc) {
    TokenData = xmlDoc.evaluate(
        '/root/theToken',
    xmlDoc.documentElement,
    null,
    XPathResult.FIRST_ORDERED_NODE_TYPE,
    null).singleNodeValue.textContent;
    return TokenData;
}

RSVP.resolve(TokenData || LoadURIPromise(TokenURL).then(evaluate))
    .then(function (token) {
    //Use Token here
    console.info(token);
});

Here is working jsFiddle

BTW, do you really need TokenData to be global?

Source Link
tomalec
  • 352
  • 4
  • 8

I have never used RSVP, I am more familiar with [Q][1], but I believe following should do what you need:

var evaluate = function (xmlDoc) {
    TokenData = xmlDoc.evaluate(
        '/root/theToken',
    xmlDoc.documentElement,
    null,
    XPathResult.FIRST_ORDERED_NODE_TYPE,
    null).singleNodeValue.textContent;
    return TokenData;
}

RSVP.resolve(TokenData || LoadURIPromise(TokenURL).then(evaluate))
    .then(function (token) {
    //Use Token here
    console.info(token);
});

Here is working [jsFiddle][2]

BTW, do you really need TokenData to be global? [1]: https://github.com/kriskowal/q [2]: http://jsfiddle.net/tomalec/EsRkp/2/