TypeError: url_1.URL is not a constructor while trying to integre the api of hubspot

Hello guys:
can anyone on how can i link react js project to hubspot ?
I have tried 2 method (the first one it’s suggestion Cors Problem and the second ; TypeError: url_1.URL is not a constructor).
here’s my code if someone could help:

import React, { useState } from “react”;

import { Client } from “@hubspot/api-client”;

export default function ContactForm() {

const [firstName, setFirstName] = useState(“”);

const [lastName, setLastName] = useState(“”);

const [email, setEmail] = useState(“”);

const [phoneNumber, setPhoneNumber] = useState(“”);

const [message, setMessage] = useState(“”);

const handleSubmit = async (e) => {

// console.log(import.meta.env.VITE_Hubspot_API);

e.preventDefault();

const data = {

properties: [

{“property”: “firstname”, “value”:firstName},

{“property”: “lastname”, “value”:lastName},

{“property”: “email”, “value”:email},

{“property”: “phone”, “value”:phoneNumber},

{“property”: “message”, “value”:message},

],

};

const hubspotClient = new Client({accessToken: import.meta.env.VITE_Hubspot_API});

console.log(hubspotClient);

try{

const createContactResponse = await hubspotClient.crm.contacts.basicApi.create(data);

console.log(createContactResponse);

}catch(e){

console.error(e);

}

setFirstName(“”);

setLastName(“”);

setEmail(“”);

setPhoneNumber(“”);

setMessage(“”);

};

return (

<form onSubmit={handleSubmit} className=“mt-[15%]”>

<input name=“firstname” placeholder=“First Name” value={firstName} onChange={(e) => setFirstName(e.target.value)}/>

<br />

<input name=“lastname” placeholder=“Last Name” value={lastName} onChange={(e) => setLastName(e.target.value)}/>

<br />

<input name=“email” placeholder=“Email” value={email} onChange={(e) => setEmail(e.target.value)}/>

<br />

<input name=“phoneNumber” placeholder=“Phone Number” value={phoneNumber} onChange={(e) => setPhoneNumber(e.target.value)}/>

<br />

<input name=“message” placeholder=“Please add information regarding your inquiry” value={message} onChange={(e) => setMessage(e.target.value)}/>

<br />

<button type=“submit”>Submit</button>

</form>

);

}

Hi @SBouhamidi, I hope that you are well!
Thank you for asking the Community and for sharing the code!
Just to clarify and so that we help you the best we can, what are you trying to achieve with the API call, please?
I’d like to invite a couple of subject matter experts to this conversation: Hi @BJunior, @himanshurauthan, @GRajput and @zach_threadint do you have suggestions to help @SBouhamidi, please?
Thanks a lot and have a great day!
Best,
Bérangère

Thank you for your feesback. What I want to acheive is when the user will fill the form, they will be added to hubspot contacts? I used React js for frontend … and i want to integrate hubspot’api (as backend)