Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

How do I make a javascript return value from promise?

Asked by Peter Wilkins Oct 13, 2022 1.2K views 1 answer
Share

About this question

I have a spec from a client for an implementation of a method in a module:

// getGenres():
 //  Returns a promise. When it resolves, it returns an array.
If given an array of genres,
['comedy', 'drama', 'action']
Here is a skeleton method with a promise:
MovieLibrary.getGenres = function() {
  var promise = new Promise(function(resolve, reject) {
    /* missing implementation */
  });
return promise;
};

Can the promise be made to return the data found in the genres? Is there a better way to achieve the spec description?


Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.