Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
request.setMethod('GET');
HttpResponse response = http.send(request);
// If the request is successful, parse the JSON response.
if (response.getStatusCode() == 200) {
// Deserialize the JSON string into collections of primitive data types.
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
// Cast the values in the 'animals' key as a list
List<Object> animals = (List<Object>) results.get('animals');
System.debug('Received the following animals:');
for (Object animal: animals) {
System.debug(animal);
}
}
Id Name
0030K00001p3ReGQAU Barr Tim
0030K00001p3ReHQAU Bond John
0030K00001p3ReJQAU Boyle Lauren
0030K00001p3ReLQAU Davis Josh
0030K00001p3ReQQAU D'Cruz Liz
0030K00001rMwdWQAS ddd
0030K00001p3ReCQAU Forbes Sean
0030K00001p3ReRQAU Frank Edna
0030K00001p3ReBQAU Gonzalez Rose
0030K00001p3ReSQAU Green Avi
0030K00001p3ReMQAU Grey Jane
0030K00001p3ReOQAU James Ashley
0030K00001rMylnQAC jjj
0030K00001p3ReKQAU Levy Babara
0030K00001p3ReUQAU Llorrac Jake
0030K00001p3ReTQAU Nedaerk Siddartha
0030K00001p3ReIQAU Pavlova Stella
0030K00001p3RePQAU Ripley Tom
0030K00001p3ReDQAU Rogers Jack
0030K00001p3ReNQAU Song Arthur
public class LeadController {
//手順6
@AuraEnabled
public static List<Lead> findAll() {
return [SELECT Id, LastName, Company FROM Lead ORDER BY LastModifiedDate DESC LIMIT 50];
}
//手順7
@AuraEnabled
public static Lead create(Lead ld) {
insert ld;
return ld;
}
}
public class LeadController {
@AuraEnabled
public static List<Lead> findAll() {
return [SELECT Id, LastName, Company FROM Lead ORDER BY LastModifiedDate DESC LIMIT 50];
}
}