fetch-salesforce
v2.0.1
Published
A client for Salesforce using React Native friendly Fetch requests.
Downloads
145
Readme
fetch-salesforce
fetch-salesforceis a wrapper for the Salesforce.com REST API using the Fetch API. This library was initially developed to be used in React Native projects that needed to access the Salesforce API, but it can be used in any environment that supportsfetch.
Install
yarn add fetch-salesforceUsage
Setup
import { SalesforceOptions, FetchSalesforce } from "fetch-salesforce";
const options: any = {
clientID: "",
authorizationServiceURL: "",
tokenServiceURL: "",
redirectUri: "",
apiVersion: 39.0,
logLevel: "DEBUG",
};
const fetchSalesforce = new FetchSalesforce(options);Insert
fetchSalesforce.fetchSObject
.insert("Account", {
Name: "My Account",
})
.then(res => {
console.log(res);
});Query
fetchSalesforce.fetchQuery
.query("SELECT ID FROM Account LIMIT 10")
.then(res => {
console.log(res);
});... you get the idea!
My target doesn't support fetch
Use a library like cross-fetch to polyfill/ponyfill it:
$ yarn add cross-fetchAs a ponyfill:
import fetch from "cross-fetch";As a polyfill:
import "cross-fetch/polyfill";Developing fetch-salesforce
Install
git clone https://github.com/kidtsunami/fetch-salesforce
cd fetch-salesforceCompiling
tscRunning Tests
yarn test