You get your data back by restoring from a backup. If you do not want to do that manually with a computer, Apple makes it very easy to do with iCloud. Once your device is reset, all data is wiped from the device, which is why having a backup is essential and strongly recommended. So much so that Apple has backups turned on by default when setting up a new phone and you have to actually shut it off to stop it from backing up. Without a backup or syncing iCloud, all data is lost.
Restore your iPhone, iPad, or iPod touch from a backup - Apple Support