Created
August 17, 2019 04:29
-
-
Save zzdjk6/7d815ca094d6d7c195c8e04da5dcf252 to your computer and use it in GitHub Desktop.
WKWebView CORS Solution: sendRequest.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sendNativePostRequest = (url, params) => { | |
return new Promise((resolve, reject) => { | |
const uuid = uuidv4(); | |
_.set(window, `jsCallbackBridge.promises.${uuid}`, { resolve, reject }); | |
const body = ''; //TODO: construct body | |
window.webkit.messageHandlers.native.postMessage({ | |
type: 'SEND_HTTP_REQUEST', | |
url, | |
body, | |
method: 'POST', | |
uuid, | |
accept: 'application/json', | |
content_type: 'application/x-www-form-urlencoded; charset=utf-8' | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment