Skip to content

How to get data asynchronously and transfer to javascript #41

Closed
@chenfengbri

Description

@chenfengbri

I used AFNetWorking to fetch data from remote service API, when the data ready, I tried to transfer the data back to javascript, but it raise an error. Any advice is appreciate. My code look like this.

^(id data, WVJBResponseCallback responseCallback) {
            NSLog(@"data: %@", data);
            NSString *service = [data objectForKey:@"service"];
            BOOL needLogin = [[data objectForKey:@"needLogin"] boolValue];
            NSDictionary *businessParams = [data objectForKey:@"businessParams"];

            [[AHAPIClient sharedClient] consumeRemoteService:service
                                                   needLogin:needLogin
                                              withParameters:businessParams
                                                     success:^(id JSON) {
                                                         responseCallback(JSON);
                                                     }
                                                     failure:^(NSError *error) {
                                                         responseCallback(error.userInfo);
                                                     }];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions