Discover how to seamlessly integrate v0 with GetResponse. Follow our step-by-step guide for easy setup and enhanced email marketing performance.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
getResponseService.ts in your project’s source directory.getResponseService.ts:
export class GetResponseService {
private apiKey: string;
private apiUrl: string = "https://api.getresponse.com/v3";
constructor(apiKey: string) {
this.apiKey = apiKey;
}
async addContact(email: string, name: string, campaignId: string): Promise {
const url = ${this.apiUrl}/contacts;
const payload = {
email: email,
name: name,
campaign: {
campaignId: campaignId
}
};
// If your environment does not support fetch by default and you're using Node.js,
// then uncomment the line below after installing "node-fetch" manually.
// import fetch from 'node-fetch';
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Auth-Token": api-key ${this.apiKey}
},
body: JSON.stringify(payload)
});
if (!response.ok) {
throw new Error(Request failed with status ${response.status});
}
return await response.json();
}
}
package.json file.package.json under the "dependencies" section:
{
"dependencies": {
"node-fetch": "^2.6.1"
}
}
getResponseService.ts file (uncomment the import line in the code snippet if necessary).
main.ts), import the GetResponseService class.
import { GetResponseService } from "./getResponseService";
const APIKEY = "YOURGETRESPONSEAPIKEY"; // Replace with your actual API key from GetResponse
const CAMPAIGNID = "YOURCAMPAIGN_ID"; // Replace with the desired campaign ID
const getResponseService = new GetResponseService(API_KEY);
// This function demonstrates subscribing a contact via GetResponse
async function subscribeContact() {
try {
const result = await getResponseService.addContact("example@example.com", "John Doe", CAMPAIGN_ID);
console.log("Contact successfully added:", result);
} catch (error) {
console.error("Error adding contact:", error);
}
}
// Call the function where appropriate in your application
subscribeContact();
config.ts) to manage configuration:
export const CONFIG = {
GETRESPONSEAPIKEY: "YOURGETRESPONSEAPI_KEY",
GETRESPONSECAMPAIGNID: "YOURCAMPAIGNID"
};
main.ts:
import { CONFIG } from "./config";
import { GetResponseService } from "./getResponseService";
const getResponseService = new GetResponseService(CONFIG.GETRESPONSEAPIKEY);
// Use CONFIG.GETRESPONSECAMPAIGNID where necessary
getResponseService.ts and optionally config.ts) and ensure they are correctly referenced in your project.subscribeContact() or integrating it within your app’s business logic.When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.