import { axiosInstances } from "./axiosInstanc"
interface upladPdfPayload {
name: string;
pdf: File
}
export const uploadPdfApi = async (payload: upladPdfPayload) => {
try {
console.log(payload);
const res = await axiosInstances.post('/pdf/upload', payload);
return res.data;
} catch (error: any) {
return error.response.data;
}
}
The following details are shown in the console: Name: 'Research paper certificate.pdf' Name: "Research paper certificate.pdf" PDF: File Last Modified: 1713083292691 Last Modified Date: Sun Apr 14 2024 13:58:12 GMT+0530 (India Standard Time) Size: 937460 Type: "application/pdf"
Axios Instance:
import axios from "axios";
import { baseUrl } from "./baseUrl";
function getToken() {
return localStorage.getItem("token");
}
export const axiosInstances = axios.create({
baseURL: baseUrl,
headers: {
authorization: `Bearer ${getToken()}`
}
})
axiosInstances.interceptors.request.use((config) => {
config.headers.authorization = `Bearer ${getToken()}`;
return config;
});
I have tried everything by checking the console and network tab, but unfortunately, I am unable to solve it. I want to see the PDF in the network tab's payload.