Discover how to integrate Bolt.new AI with Propertybase quickly and easily. Follow our step-by-step guide to enhance your property management workflow efficiently.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
propertybaseIntegration.ts
.
YOURAPIKEY_HERE
with your actual Propertybase API key and adjust apiUrl
if necessary.)
import fetch from 'node-fetch';
export interface LeadData {
firstName: string;
lastName: string;
email: string;
phone?: string;
// Add additional fields as needed
}
export async function sendLeadToPropertybase(lead: LeadData): Promise {
const apiUrl = 'https://api.propertybase.com/leads'; // Adjust to your Propertybase endpoint if needed
const apiKey = process.env.PROPBASEAPIKEY || 'YOURAPIKEY_HERE';
const headers = {
'Content-Type': 'application/json',
'Authorization': Bearer ${apiKey}
};
try {
const response = await fetch(apiUrl, {
method: 'POST',
headers: headers,
body: JSON.stringify(lead)
});
if (!response.ok) {
throw new Error('Failed to send lead to Propertybase');
}
return await response.json();
} catch (error) {
console.error('Error in sendLeadToPropertybase:', error);
throw error;
}
}
main.ts
or the file where you handle lead submissions).
import { sendLeadToPropertybase, LeadData } from './propertybaseIntegration';
sendLeadToPropertybase
function. For instance:
// Example function to handle a new lead submission
async function handleNewLeadSubmission(formData: any) {
// Map your formData to the LeadData interface
const lead: LeadData = {
firstName: formData.firstName,
lastName: formData.lastName,
email: formData.email,
phone: formData.phone
};
try {
const result = await sendLeadToPropertybase(lead);
console.log('Lead successfully sent to Propertybase:', result);
// You can further process the response as needed
} catch (error) {
console.error('Error sending lead to Propertybase:', error);
// Handle error (like showing an error message in your UI)
}
}
// Example usage if you have an event listener for form submission
document.getElementById('leadForm')?.addEventListener('submit', async (event) => {
event.preventDefault();
const formData = {
firstName: (document.getElementById('firstName') as HTMLInputElement).value,
lastName: (document.getElementById('lastName') as HTMLInputElement).value,
email: (document.getElementById('email') as HTMLInputElement).value,
phone: (document.getElementById('phone') as HTMLInputElement).value,
};
await handleNewLeadSubmission(formData);
});
node-fetch
dependency, add the following at the very top of your main file to ensure the module is loaded. (Make sure that the node-fetch
library is available in your project’s environment or bundle the dependency manually.)
import fetch from 'node-fetch';
process.env.PROPBASEAPIKEY = 'YOURACTUALPROPERTYBASEAPIKEY';
Insert this code in your main file before any calls to sendLeadToPropertybase
are made.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.