refactoring angular; fix get posts api