Skip to content

Commit

Permalink
made it for production
Browse files Browse the repository at this point in the history
  • Loading branch information
faisal-kn committed Dec 27, 2021
1 parent 7b6405d commit 4174fd2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
28 changes: 11 additions & 17 deletions src/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,18 @@ import axios from "axios";
const Direct = () => {
const { shortenedURL } = useParams();

const getURL = async () => {
const options = {
url: `https://urlshortdev.herokuapp.com/api/v2/shorturl/${shortenedURL}`,
method: "GET",
withCredentials: true,
};
const res = await axios(options);
console.log(res);
return res.data.data.url.fullUrl;
};

React.useEffect(() => {
getURL().then((res) =>
window.open(
res,
"_blank"
)
);
const getURL = async () => {
const options = {
url: `https://urlshortdev.herokuapp.com/api/v2/shorturl/${shortenedURL}`,
method: "GET",
withCredentials: true,
};
const res = await axios(options);
console.log(res);
return res.data.data.url.fullUrl;
};
getURL().then((res) => window.open(res, "_blank"));
}, [shortenedURL]);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ReactDOM from "react-dom";
import App from "./App";
import classes from "./index.module.css";
import "./index.module.css";
import { BrowserRouter } from "react-router-dom";

ReactDOM.render(
Expand Down
1 change: 0 additions & 1 deletion src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import classes from "./Home.module.css";
import AuthContext from "../context/auth-context";
import axios from "axios";
import Table from "./Table";
import Spinner from "../components/Spinner";

const Home = (props) => {
const ctx = React.useContext(AuthContext);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { NavLink, Route, useHistory } from "react-router-dom";
import { NavLink, useHistory } from "react-router-dom";
import axios from "axios";

import classes from "./Login.module.css";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Table.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useEffect, useState } from "react";
import styles from "./Table.module.css";
import "./Table.module.css";
import axios from "axios";
import { NavLink } from "react-router-dom";
import { usePromiseTracker } from "react-promise-tracker";
Expand Down

0 comments on commit 4174fd2

Please sign in to comment.