SharePoint Online Troubleshooting: Uncaught TypeError: SP.ProxyWebRequestExecutorFactory is not a function
Environment
Office 365, SharePoint Online, Visual Studio 2015, SharePoint JSOM
Error
Uncaught TypeError: SP.ProxyWebRequestExecutorFactory is not a function
Error occurred at the highlighted line of code below
hostwebUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
appwebUrl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
context = new SP.ClientContext(appwebUrl);
factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);
Troubleshooting
According to this MSDN article, SP.ProxyWebRequestExecutorFactory is member of Request Executor(sp.requestexecutor.js). So the script file should be loaded explicitly in the page in order to avoid the error.
Fix
Reference the SP.RequestExecutor.js in the page
<script type="text/javascript" src="/_layouts/15/SP.RequestExecutor.js"></script>