Changed todoApi to a factory