There's more...

You may have noticed that the Network tab doesn't show the API calls done from the app. With RN, we solved that because the tools we used included the ability to inspect all network traffic, but that doesn't happen here. So, instead of an easy, automated solution, we'll have to do a bit of extra work. If you do all of your API calls with axios, you can simply modify its original methods to produce logging:

// Source file: src/regionsApp/serviceApi.js

.
.
.

axios.originalGet = axios.get;
axios.get = (uri, options, ...args) =>
axios.originalGet(uri, options, ...args).then(response => {
console.log(`GET ${uri}`, {
request: { uri, options, ...args },
response
});
return response;
});

The change shown will cause every successful GET to log everything you need, as in the following screenshot:

Our changed axios.get() method produces a satisfying log

Of course, this is just the tip of the required changes. You'll have to add code for a failed call (so, add some logging in .catch(), too) and you'll also want to do this sort of change for the other methods (.post(), .delete(), and so on), but the necessary code is simple, so I'll leave it as an exercise for the reader!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.25.74