In case I have
import axios from "axios";
function model() {
function getAll() {
return axios
.get("http://localhost:3000/teams")
.then(response => response.data);
}
}
export default model;
How can I access getAll() method from another component ?
I tried importing model and then referring it to getAll - model.getAll(), but it complains that the method is undefined.
I tried referring to Calling a Function defined inside another function in Javascript , but could not find the solution.
Is this even the correct approach?
getAllfrommodel()export default axios.get(....and just import teamsimport teams from './teams';teams.then(teams=>....