You need to sign in to do that
Don't have an account?
Sanjana Rajasekar
Lightning Out App in external websites
I have Created a Visual Force Page. When I preview it I could see the what I have created. I am trying to use the VF page to NodeJs .Wanted to see the same functionality in local server. I created a server running on port 3000. When I run the server, the page keeps on loading. Can someone help what is wrong in my code? Thanks in advance.
app.js
const express = require('express')
const jsforce = require('jsforce')
var fs = require('fs');
require('dotenv').config()
const app = express()
const PORT = 3000
const {SF_LOGIN_URL,SF_USERNAME,SF_PASSWORD,SF_TOKEN} = process.env
const conn = new jsforce.Connection({
loginUrl : SF_LOGIN_URL
})
conn.login(SF_USERNAME,SF_PASSWORD+SF_TOKEN,(err, userinfo)=>{
if(err){
console.log(err)
}else{
console.log("user id : "+userinfo.id)
console.log("Org id : "+userinfo.organizationId)
}
})
app.get('/',(req,res)=>{
fs.readFile('./index.html', function (err, html) {
if(err){
console.log('Script Error'+err)
}else{
res.write(html);
}
})
})
app.listen(PORT,()=>{
console.log(`Server is Running at http://localhost:${PORT}`)
})
index.html
<script src="https://wellcorp--n28hcdev.sandbox.lightning.force.com/lightning/lightning.out.js"></script>
<script>
$Lightning.use("c:SchedulerApp",
function() { // Callback once framework and app load
$Lightning.createComponent(
"c:SchedulerCmp", // top-level component of your app
{ }, // attributes to set on the component when created
"lexcontainer", // the DOM location to insert the component
function(component) { // API name of the Flow
}
);
}, 'https://wellcorp--n28hcdev.sandbox.my.salesforce.com/' // Site endpoint
);
</script>
app.js
const express = require('express')
const jsforce = require('jsforce')
var fs = require('fs');
require('dotenv').config()
const app = express()
const PORT = 3000
const {SF_LOGIN_URL,SF_USERNAME,SF_PASSWORD,SF_TOKEN} = process.env
const conn = new jsforce.Connection({
loginUrl : SF_LOGIN_URL
})
conn.login(SF_USERNAME,SF_PASSWORD+SF_TOKEN,(err, userinfo)=>{
if(err){
console.log(err)
}else{
console.log("user id : "+userinfo.id)
console.log("Org id : "+userinfo.organizationId)
}
})
app.get('/',(req,res)=>{
fs.readFile('./index.html', function (err, html) {
if(err){
console.log('Script Error'+err)
}else{
res.write(html);
}
})
})
app.listen(PORT,()=>{
console.log(`Server is Running at http://localhost:${PORT}`)
})
index.html
<script src="https://wellcorp--n28hcdev.sandbox.lightning.force.com/lightning/lightning.out.js"></script>
<script>
$Lightning.use("c:SchedulerApp",
function() { // Callback once framework and app load
$Lightning.createComponent(
"c:SchedulerCmp", // top-level component of your app
{ }, // attributes to set on the component when created
"lexcontainer", // the DOM location to insert the component
function(component) { // API name of the Flow
}
);
}, 'https://wellcorp--n28hcdev.sandbox.my.salesforce.com/' // Site endpoint
);
</script>