Answers for "create seperate file for requests react"

0

create seperate file for requests react

1

You can do it like this 1. Create the method you want to export inside suppliers devices.js.

 SupplierServices.js
 Export const fetchData =  async () => {
 Const res =   await axios.get(your url) 
 Console.log(res) 
 }
2. Now import the fetchData method from supplierServices

Import { fetchData } from './SupplierServices'
Const Supplier = () => { 
 useEffect(.() =>{ 
 fetchData ()
 } )
}
Posted by: Guest on September-28-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language