Hi guys this is a question based on a scenario.
Implementing autocomplete widget where it,
- fetch data from backend
- render results as a tree
- support for radio, checkbox , icons
In here what does the component's API looks like?
what does the backend API looks like?
I know what is an API but this makes me really confusing.
-
1There's "API" as in "the interface for the object you define in JavaScript" and "API" as in "external resource over HTTPS, etc.", but it's not clear which you're talking about.tadman– tadman2020年12月30日 05:43:15 +00:00Commented Dec 30, 2020 at 5:43
-
@tadman not sure but these are the questions asked. I'm also not clear what they meant.Shashan Sooriyahetti– Shashan Sooriyahetti2020年12月30日 11:45:10 +00:00Commented Dec 30, 2020 at 11:45
1 Answer 1
(Disclaimer: gross oversimplification here)
API is just a way of how computers speak to each others in a very structured way.
Component's API is usually a signature of some modules/packages/functions. In other words, it's an explanation of how to interact with a component. Note, that the component can be very complex inside, but provide a very clean and easy to use API. This API describes how to use the component, what arguments to provide, what you get when running it, etc. Here is an example of a component's API - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date (in this case it's a JavaScript Date object)
A backend API is the same contract/way of interacting, but over network, like REST API or GraphQL. Backend API defines which urls/ips you need to connect to, what to send to them, and what to expect. Here is an example of BE API - https://www.teslaapi.io/vehicles/list (in this case it's Tesla's public API)