react-server-dom-webpack/client
Unanswered
Jersey Wooly posted this in #help-forum
Jersey WoolyOP
While "npm run dev" - all is ok
When "npm run build" - i've this error
Logic:
1. send_lead.js file (@/lib/send_lead.js)
2. Client side btn button.js:
When "npm run build" - i've this error
Logic:
1. send_lead.js file (@/lib/send_lead.js)
"use server";
export default async function SendLead({
msg = "someText",
}) {
const tgbot = process.env.LEAD_BOT_API;
const idTo = process.env.CHANAL_ID;
try {
const options = {
method: "POST",
headers: {
accept: "application/json",
"content-type": "application/json",
},
body: JSON.stringify({
text: escapeReservedCharacters(msg),
parse_mode: "MarkdownV2",
disable_web_page_preview: false,
disable_notification: false,
reply_to_message_id: null,
}),
};
await fetch(
`https://api.telegram.org/bot${tgbot}/sendMessage?chat_id=${idTo}`,
options
);
return true;
} catch (err) {
console.log(err);
return false;
}
}2. Client side btn button.js:
"use client";
import SendLead from "@/lib/send_lead";
export default function SomeClientBtn(){
return(
<button onClick={goSendLead}>
<span>Try it</span>
</button>
)
async function goSendLead() {
const reqStatus = await SendLead({
msg: "hello",
});
alert(reqStatus);
}
}