I am working on implementing a design where a developer can easily switch between a local JSON file or its corresponding API.
Scenario :
-
We have
https://jsonplaceholder.typicode.com/todos/1
with corresponding json asuser1.json
. -
We have
https://reqres.in/api/users/2
withuser2.json
I have created a config.json
which has a mapping :
[
{
"url":"https://jsonplaceholder.typicode.com/todos/1",
"json" : "/assets/user1.json",
"local": true
},
{
"url": "https://reqres.in/api/users/2",
"json" : "assets/user2.json",
"local": false
}
]
Now, if you toggle local
property of each object, you can see that it toggles between local JSON and REST API calls.
I would really like to get some feedback on my implementation and get to know about potential problems which I might face(if any) in future with this design
Here is the implementation which I have thought about
Aucun commentaire:
Enregistrer un commentaire