Skip to content

Commit

Permalink
Update video download API to use axios instead of fetch (generated b…
Browse files Browse the repository at this point in the history
…y blackbox.ai )
  • Loading branch information
saiyamdubey committed Feb 13, 2024
1 parent 3147cf6 commit ca2affd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/instagram/video/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useState } from "react";
import { GoPaste } from "react-icons/go";
import { toast } from "sonner";
import Loader from "../loader";
import axios from "axios";

type Props = {};

Expand All @@ -26,11 +27,11 @@ function Searchbar({}: Props) {
return toast("Check the Provided Link");
}

const response = await fetch(
const response = await axios.get(
`/api/download?url=${encodeURIComponent(url)}`
);
console.log(response);
const data = await response.json();
const data = response.data;
console.log(data);

if (data === "link is wrong") {
Expand Down
10 changes: 5 additions & 5 deletions pages/api/download.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { NextApiRequest, NextApiResponse } from 'next';
// import axios from 'axios';
import axios from 'axios';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
let { url } = req.query;

Expand All @@ -14,10 +14,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}

try {
console.log("hello")
const response = await fetch(url as string);

const data = await response.json();
console.log("hello1")
const response = await axios.get(url as string);
console.log(response.data)
const data = response.data;
res.status(200).send(data);
} catch (error) {
res.status(500).send('error');
Expand Down

1 comment on commit ca2affd

@vercel
Copy link

@vercel vercel bot commented on ca2affd Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.