0

I have a problem. I badly need a value that is inside my promise. I need to process it further. It is not possible for me to return promise.

My code:

function func(http: NpHttp, context: {
    obj: Obj
}) {
    var list: Obj[];
    const name = context.obj.name;
    var allowed = true;
    var result = http.get < ObjectList > ('/objects')
        .then(({
            data
        }) => {
            list = data.objects;
            console.log(list);
            return !list.some(t => t.name === name);
        })
        .then(function(data) {
            console.log("Value: " + data);
            allowed = data;
            return data;
        });
    return () => allowed;
}

The value of allowed changes only inside callback, but not in general. Please help

KompiKompi
  • 400
  • 4
  • 22

0 Answers0