Skip to content
This repository was archived by the owner on Jan 27, 2024. It is now read-only.

Commit 28cafe8

Browse files
committed
update readme
1 parent 9a120fc commit 28cafe8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
A simple [promise-based](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_promises.htm)
44
[service component](https://developer.salesforce.com/blogs/2018/08/implement-and-use-lightning-service-components.html)
5-
for working with Salesforce REST API
5+
for working with Salesforce REST API and JavaScript Fetch API
66
directly from your component's JavaScript without you needing to
77
write Apex or configure Named Credentials. Just install and use.
88

@@ -11,15 +11,15 @@ write Apex or configure Named Credentials. Just install and use.
1111

1212
1. Deploy this project to your org (you only need what's in `force-app` folder).
1313

14-
2. Explore the `LC_Demo` component in the `force-demo` folder on usage.
14+
2. Explore the `LC_RequestDemo` and `LC_FetchDemo` components in the `force-demo` folder on usage.
1515

1616
3. Try out a demo
1717

1818
a. Assign yourself the **LC Demo** permission set.
1919

2020
b. Navigate to the **LC Demo** tab.
2121

22-
c. Play with the sample components to send different REST API requests.
22+
c. Play with the sample components to send different [REST API](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_what_is_rest_api.htm) and [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) requests.
2323

2424
d. Marvel that you didn't have to write any Apex code or configure a Named Credential :)
2525

@@ -31,19 +31,21 @@ Add the `<c:lc_api>` to your component and give it an `aura:id` for reference.
3131
```xml
3232
<!-- YourComponent.cmp -->
3333
<aura:component>
34-
<c:lc_api aura:id="restClient"/>
34+
<c:lc_api aura:id="lc_api"/>
3535
...
3636
</aura:component>
3737
```
3838

39-
Find the `<c:lc_api>` by its `aura:id` then call the `restRequest(..)` method passing in the `url`, `method`, `body`, and any `headers`.
39+
Find the `<c:lc_api>` by its `aura:id` then call one of the request methods:
40+
* The `restRequest(..)` method passing in a JSON object with the `url`, `method`, `body`, and any `headers` properties, or
41+
* The `fetchRequest(..)` method passing in a JSON object with the `url` and `options` properties
4042

4143
```js
4244
// YourComponentController.js
4345
({
4446
createAccount: function( component, event, helper ) {
4547

46-
component.find( 'restClient' ).restRequest({
48+
component.find( 'lc_api' ).restRequest({
4749
'url' : '/services/data/v45.0/sobjects/Account',
4850
'method' : 'post',
4951
'body' : JSON.stringify({
@@ -79,7 +81,7 @@ Because the two domains do not match, then CORS policy prevents the request.
7981

8082
[Doug Ayers](https://douglascayers.com) develops and maintains the project.
8183

82-
[Postmate](https://github.com/dollarshaveclub/postmate)
84+
[Penpal](https://github.com/Aaronius/penpal)
8385
for a secure, promise-based library for communicating between windows and iframes.
8486

8587
[jsforce](https://jsforce.github.io/)

0 commit comments

Comments
 (0)