A simple util to avoid repeating if/else logic when sending API data.