kidtsunami / fetch-salesforce Goto Github PK
View Code? Open in Web Editor NEWAccessing the Salesforce API using node-fetch to support React-Native projects
Accessing the Salesforce API using node-fetch to support React-Native projects
there is an endpoint to revoke a token: /services/oauth2/revoke
in the simulator: self is not defined
in xcode:
2016-11-19 15:04:09.598 [warn][tid:NSOperationQueue 0x618000224800 :: NSOperation 0x61000004ad40 (QOS: DEFAULT)][RCTModuleData.mm:220] RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
2016-11-19 15:04:11.239 [warn][tid:main][RCTEventEmitter.m:54] Sending `websocketFailed` with no listeners registered.
2016-11-19 15:04:11.341 [error][tid:com.facebook.react.JavaScript] Can't find variable: self
2016-11-19 15:04:11.342 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Can't find variable: self
2016-11-19 15:04:11.347 [warn][tid:com.facebook.react.JavaScript] Unable to symbolicate stack trace: fetch is not a function. (In 'fetch(devServer.url+'symbolicate',{
method:'POST',
body:JSON.stringify({stack:stack})})', 'fetch' is undefined)
2016-11-19 15:04:11.387 [info][tid:main][RCTRootView.m:239] Running application PatientSupportMobileAccelerator ({
initialProps = {
};
rootTag = 1;
})
2016-11-19 15:04:11.388 [error][tid:com.facebook.react.JavaScript] Module AppRegistry is not a registered callable module (calling runApplication)
2016-11-19 15:04:11.389 [warn][tid:com.facebook.react.JavaScript] Unable to symbolicate stack trace: fetch is not a function. (In 'fetch(devServer.url+'symbolicate',{
method:'POST',
body:JSON.stringify({stack:stack})})', 'fetch' is undefined)
2016-11-19 15:04:11.389 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Module AppRegistry is not a registered callable module (calling runApplication)
We need to add a catch
block to the fetchJSON
promise chain here: https://github.com/kidtsunami/fetch-salesforce/blob/master/src/lib/fetcher.ts#L118
@kidtsunami as you suspected, the response.json()
issue i reported earlier today was a result of Salesforce returning a 204
and no content. We should study the jsforce
source and handle the various status codes accordingly: https://github.com/jsforce/jsforce/blob/38e4e66d021db20b22435f48c9d2b34f48e54c23/lib/http-api.js#L161
EDIT: looks like 300/204 are the only ones we're not explicitly handling. 204 is most important for now.
We need the ability to set the X-Connect-Bearer-Urls
header in order to get public-facing URLs for static resources. For now, I have a hack in place but it'd be great to support this officially.
hack (line 25 of fetchChatter.js):
headers: {
'X-Connect-Bearer-Urls': true
}
@joeferraro @jpmonette y'all have maintained this for a little bit. A few questions:
see: http://jsforce.github.io/jsforce/doc/OAuth2.html
http://jsforce.github.io/jsforce/doc/oauth2.js.html#line63
it would be nice to be able to set up my RN webview with a url that's generated by my fetch-salesforce client based on the client id, login url, and redirect uri
client should be able to assign a callback to token refresh
url is in the format: BASE_URL+'apexrest/some/custom/endpoint'
POST/PATCH/GET/DELETE
for times when token is being refreshed, library should still collect requests in a buffer then retry them all once access token is refreshed
i should be able to pass an api version
React Native displays console.error
messages in a big ugly red screen (e.g. when we have an error like an invalid_grant
, which is basically a signal to the client that they need to re-authenticate). Given this library is most likely to be used for React Native, we should consider implementing a proper logging module that makes log levels and output configurable. At the very least, in the immediate term, we should change console.error
statements to warn
or log
.
url looks like so:
GET request, requires Authorization header
var userInfoEndpoint = 'https://'+BASE_URL+'/services/oauth2/userinfo';
Getting the following warning when refreshing access token, can you please investigate @kidtsunami?
insert, update, delete, upsert, etc.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.