Fetch API provides an interface for fetching resources (including across the network). This API is similar to XMLHttpRequest usage (swipe to right to see that same example with it). But the Fetch API provides a more powerful and flexible usage 😉. To make a request and fetch a resource use the fetch() global function with the path of resource in param.
This function returns a Promise. So with this you can get response with .then() and catch error with .catch(). This is a simple example of fetch API. In this example we use the API for request resources from JSONPlaceholder. You can see the .then() twice. The first is like a map, where we convert the response to JSON format and in the second we get the response already formatted.
Fetch API also provides the usage of Headers, CORS and so on. This is passed in the second param. For more informations about that, you can see the MDN Website.
That's all, see ya!
#sunday turned into a coding day writing #php classes/methods to communicate with #filemaker. Towards the end of the day it looked like we were going to have a brilliant #sunset - jumped on a #gobikihi and headed to Magic Island to say #aloha to the ☀️
Digging deeper into using the full MVC stack of ASP .NET Core 2.1. Right now I’m learning about URL routing and how the routes map to the controller, an action method, and function arguments. Up next we’re going to start passing data from a form to a database and set up an API to send JSON to a client. Also going to start using Git and explore unit testing. Definitely enjoying this course and all the tools I’m going to learn along the way.