function for a synchronous request