Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
178 views
in Technique[技术] by (71.8m points)

javascript - Difference between component API and Backend API?

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

(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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...