adding fetching data function in js file