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

  • Home
  • SEARCH
  • 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
  • 0 Views
  • 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 am working with ASP.NET doing some client side javascript. I have the following
I'm at a client doing some quick fixes to their access application. It was
I have some cross platform DNS client code that I use for doing end
Currently I'm doing some unit tests which are executed from bash. Unit tests are
I've been doing some mocking with RhinoMocks and it requires that mocked methods be
I have a form in my content page for which I am doing some
I am doing some work on a legacy project, one that has been upgraded
After doing some work with Ruby, Rails, and RSpec last summer and I learned
I'm doing some PHP stuff on an Ubuntu server. The path I'm working in
I'm doing some funky authentication work (and yes, I know, open-id is awesome, but

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.