Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1056499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:43:24+00:00 2026-05-16T17:43:24+00:00

Doing some client-side JavaScript development, which requires me to call a client-side API which

  • 0

Doing some client-side JavaScript development, which requires me to call a client-side API which only accepts one parameter at a time (cough, cough, facebook).

Basically i need to call an API method twice:

someFBApi.requestPerms('email')
someFBApi.requestPerms('publish_stream')

Now, i have a wrapper function for this call which looks like this:

function requestPermission(permission, callback) {
 someFBApi.requestPerms(permission, callback);
}

But the problem is, i have to call the function “requestPermission” twice from all over the place:

requestPermission('email', function(perm1granted) {
   requestPermission('publish_stream', function(perm2granted) {
      // do something with perm 1 and perm 2

I would like to be able to do this:

requestPermissions('email,publish_stream', function(firstPerm,secondPerm) {
   // do something with firstPerm, secondPerm

I know i have to call FB API twice (fine), but i want that ‘doubling up’ to occur in that function (not all over the place). Know what i mean?

So, i’ll accept an answer of two forms:

  • Can i pass an array of strings, iterate through those? (maybe JSON?)
  • Delimeted-string, then split the string in the function.

Keep in mind the function returns a value indicating whether or not the permission was granted. So it needs to accept an array/delimited list of strings and return an array/delimited list of strings.

The more simple the solution, the better. (jQuery fine)

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:43:24+00:00Added an answer on May 16, 2026 at 5:43 pm

    Don’t be tempted to use the string parsing solution. An array is cleaner and simpler:

    /* note: permisions is expected to be an array */
    function requestPermission(permissions) {
        for (var i=0; i<permissions.length; i++) {
            doSomething(permissions[i]);
        }
    }
    

    Now, the only problem would seem to be what to do with the callback. I’m assuming that the API is asynchronous and you’d want something like this:

    doSomething(when_done)->doSomething...(finally)->execute_callback
    

    For that you can use a sort of recursion. Except it wouldn’t really be recursion in the traditional sense since each call happen asynchronously. Something like:

    /* note: permisions is expected to be an array */
    function requestPermission(permissions,callback) {
        var p = permissions.shift();
        var f = callback;
        if (permissions.length > 0) {
            // if this is not the last permission then
            // call this function again in the callback:
            f = function () {
                requestPermission(permissions,callback);
            }
        }
        someFBApi.requestPerms(p,f);
    }
    

    Now you can use it like this:

    requestPermissions(['email','publish_stream'],finalCallback);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some client-side stuff with Javascript/JQuery with .Net controls which expose their GUID/UniqueIdentifier
I'm currently writing a client-side javascript app which performs image manipulation. Some of the
I am working with ASP.NET doing some client side javascript. I have the following
I am doing some client side validation in ASP.NET MVC and I found myself
I'm doing some wsdl- and client-first development in C# with WCF (the wsdl and
I'm currently creating some custom attributes for doing uploaded file validation. One of which
I have been thinking of doing some development with backbone.js javascript framework and i
I just want to add some client side (JQuery Javascript) validation in a web
I am coding a E-commerce website/admin interface for a client. They are doing some
While doing some JavaScript performance tests I came up with the following piece of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.