Generic fetch function