Skip to content

Commit 80e8ea8

Browse files
committed
Rename port variables to fix typescript duplicate identifier clash.
1 parent 0bf80fb commit 80e8ea8

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

chat-app/client/src/App.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ function App() {
1313
const [formChat, setFormChat] = useState({ ...initialForm });
1414
const [alert, setAlert] = useState("");
1515
const [messageType, setMessageType] = useState("");
16-
const port = "https://backendchatapp.hosting.codeyourfuture.io/api";
17-
const port2 = "wss://backendchatapp.hosting.codeyourfuture.io";
16+
const backend_url = "https://backendchatapp.hosting.codeyourfuture.io/api";
17+
const socket_url = "wss://backendchatapp.hosting.codeyourfuture.io";
1818

1919
const showNotification = (msg: string, type: string = "success") => {
2020
setAlert(msg);
@@ -24,7 +24,7 @@ function App() {
2424

2525
const arrayMessages = async () => {
2626
try {
27-
const response = await fetch(`${port}/messages`, {
27+
const response = await fetch(`${backend_url}/messages`, {
2828
method: "GET",
2929
});
3030

@@ -48,7 +48,7 @@ function App() {
4848

4949
useEffect(() => {
5050
// Open the pipeline
51-
const socket = new WebSocket(port2);
51+
const socket = new WebSocket(socket_url);
5252
// log if it open
5353
socket.onopen = () => {
5454
console.log("Connected to the backend WebSocket conductor.");
@@ -88,7 +88,7 @@ function App() {
8888
socket.close();
8989
console.log("WebSocket connection cleanly closed.");
9090
};
91-
}, [port2]);
91+
}, [socket_url]);
9292

9393
const handleFormChat = async (e: React.FormEvent<HTMLFormElement>) => {
9494
e.preventDefault();
@@ -97,7 +97,7 @@ function App() {
9797
return;
9898
}
9999
try {
100-
const response = await fetch(`${port}/messages`, {
100+
const response = await fetch(`${backend_url}/messages`, {
101101
method: "POST",
102102
headers: { "Content-Type": "application/json" },
103103
body: JSON.stringify(formChat),
@@ -123,7 +123,7 @@ function App() {
123123
action: "like" | "dislike",
124124
) => {
125125
try {
126-
const response = await fetch(`${port}/messages/${messageId}`, {
126+
const response = await fetch(`${backend_url}/messages/${messageId}`, {
127127
method: "PATCH",
128128
headers: { "Content-Type": "application/json" },
129129
body: JSON.stringify({ action }),

0 commit comments

Comments
 (0)