how to get data from rest api in javascript