add promise javascript snippet