Skip to content

Commit

Permalink
Replace axios with fetch API (generated by blackbox.ai )
Browse files Browse the repository at this point in the history
  • Loading branch information
saiyamdubey committed Feb 14, 2024
1 parent 8325db8 commit 2f7306a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
20 changes: 13 additions & 7 deletions app/instagram/video/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useState } from "react";
import { GoPaste } from "react-icons/go";
import { toast } from "sonner";
import Loader from "../loader";
import Loader from "../../../components/loader";
import axios from "axios";

type Props = {};
Expand All @@ -27,16 +27,22 @@ function Searchbar({}: Props) {
return toast("Check the Provided Link");
}

const response = await axios.get(
`/api/download?url=${encodeURIComponent(url)}`
const response = await fetch(
`/api/download?url=${encodeURIComponent(url)}`,
{
cache: "no-cache",
}
);
console.log(response);
const data = response.data;
const data = await response.json();
console.log(data);
const response1 = await axios.get(
`/api/test?url=https://jsonplaceholder.typicode.com/posts`
const response1 = await fetch(
`/api/test?url=https://jsonplaceholder.typicode.com/posts`,
{
cache: "no-store",
}
);
console.log(response1.data)
console.log("hi ::",await response1.json());
if (data === "link is wrong") {
setloading(false);
toast("Check the Provided Link");
Expand Down
File renamed without changes.
8 changes: 5 additions & 3 deletions pages/api/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
let { url } = req.query;

try {
const response = await axios.get(url as string );
console.log("response 1",response.data)
const data = response.data;
const response = await fetch(url as string,{
cache:"no-store"
} );
console.log("response 1",response)
const data = response.json();
res.status(200).json(data);
} catch (error) {
console.error(error);
Expand Down
4 changes: 2 additions & 2 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const config: Config = {
},

screens: {
'sm': {'min': '300px', 'max': '900px'},
'sm': {'min': '300px', 'max': '1000px'},
'md': {'min': '901px', 'max': '1024px'},
'lg': {'min': '1025px', 'max': '1279px'},
'xl': {'min': '1280px', 'max': '1400px'},
'2xl': {'min': '1401px','max':'1900px'},
'2xl': {'min': '1001px','max':'2500px'},
},

extend: {
Expand Down

0 comments on commit 2f7306a

Please sign in to comment.