The first doesn't require custom code - you need to have two identical data sources that differ by URL. Then use two similar Invoke Data Source Method actions and set the Condition to determine which one will execute.
The second method requires custom code. Something like step 3 from this tutorial (shows how to make HTTP request via custom method in the Angular component).