Introduction
This article will teach us how to upload a file to the web API in the Next JS application using Axios. We also learn how to download a file in the Next JS application.
Preconditions
- Javascript
- Basic knowledge of Next JS
- Node.js
- V.S. Code,Visual Studio
We cover the below things,
- Create Next JS application
- Upload File to API using axios in Next Js
- Download the File in Next JS
Step 1
Run the below code to create the Next JS application.
Step 2
Run the below command for installing Axios.
Create the file according to the below image.
![How to upload and download file to API in Next Js application]()
Step 3
Add the below code in the index.js.
Step 4
Add the below code in MyFileUpload.js.
Step 5
Create Home.module.css and globals.css. You can find the CSS code with the attached source code.
Step 6
Add the following code in package.json.
Step 7
Run the following commands.
![How to upload and download file to API in Next Js application]()
Summary
This article taught us how to create the Next JS project and upload files using Axios. Also, we learned how to download files from a path in Next JS.