Creating the REST API Service
I am going to show how to call a REST API to get the data for the ViewModel. There is a great fake online REST API for testing and prototyping: https://jsonplaceholder.typicode.com. For example, if we call this URL: https://jsonplaceholder.typicode.com/posts, we will get the data like this:
1
[
2
{
3
"userId": 1,
4
"id": 1,
5
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
6
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
7
},
8
{
9
"userId": 1,
10
"id": 2,
11
"title": "qui est esse",
12
"body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
13
}
14
]
Copied!
Last modified 3yr ago
Copy link