function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC Forum 9SFDC Forum 9 

@Auraenabled from private method

I have public non static method which will call couple of private methods ,one of them in turn make call to web service.

Now i will have to make them annotated with @AuraEnabled, how can I do that.

I tried making all of them static, it gices an errors

'this cannot be used in static resource'
'variable does not exist: request'

Please suggest
AnudeepAnudeep (Salesforce Developers) 
To use @AuraEnabled annotation, your Apex controller must follow these requirements.
  • Methods must be static and marked public or global. Non-static methods aren’t supported.
  • If a method returns an object, instance methods that retrieve the value of the object’s instance field must be public.
  • Use unique names for client-side and server-side actions in a component. A JavaScript function (client-side action) with the same name as an Apex method (server-side action ) can lead to hard-to-debug issues. In debug mode, the framework logs a browser console warning about the clashing client-side and server-side action names.

If it is a SOAP call, your code should look like this
global with sharing class MySOAPWebService {
    webservice static Account getRecord(String id) {
        // Add your code
    }
}

and if it is REST, it should look like this
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
    @HttpGet
    global static Account getRecord() {
        // Add your code
    }
}