Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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 ()
 } )
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #seperate #file #requests #react
ADD COMMENT
Topic
Name
5+4 =