Check out example codes for "mitmproxy on mac and android device". It will help you in understanding the concepts better.

Code Example 1

1- https://medium.com/@gaikwadchetan93/monitoring-modifying-android-app-network-traffic-via-mitm-proxy-part-1-886f6324f705

2- https://www.andyibanez.com/posts/intercepting-network-mitmproxy/

Learn ReactJs, React Native from akashmittal.com