WEBT Logs
JSON (JavaScript Object Notation) is a lightweight text format whose syntax mirrors JavaScript objects, so the browser can turn it into usable data almost for free.
JSON encodes data as key–value pairs inside { }, looking just like a JavaScript object literal:
{
"name": "Anna M...
Q What are the key differences between XML and JSON, and which is preferred for web APIs?
JSON is compact and maps straight onto JavaScript data, while XML is more verbose but supports attributes, comments, and richer schema validation — and for web APIs, JSON usually wins.
The same data shows the contrast. In XML a list of relatives needs a repeated tag for each item...
Q When fetching a stationboard, why wrap the call in try…catch and check response.ok separately?
Because fetch only rejects on network failure, not on HTTP error statuses — so you need both: try…catch for the network, and an explicit response.ok check for 4xx/5xx responses.
* fetch's two failure classes: the network rejects into catch; HTTP errors resolve and need the respo...
Q What is the difference between an XML element and an XML attribute?
An element is the content from start-tag to end-tag (including everything nested inside); an attribute is a named key="value" pair written inside the start-tag that annotates the element.
The two are XML's two places to put data, and they look different:
<book isbn="1575213966">...
Q How do you represent nested data structures in JSON?
You nest data in JSON by putting objects inside objects and using arrays of objects, to any depth — the same way you'd nest JavaScript objects and arrays.
{
"person": {
"name": "Anna",
"address": {
"street": "Main St",
"city": "Zurich"
},
"phones": [...
Q How does frontend (client-side) webservice integration work?
In frontend integration the user's browser calls the external API directly with JavaScript after the page has loaded — your own webserver is not involved in those calls.
The flow has two distinct phases. First the page is delivered normally; then the JavaScript on it talks to the...
Q How does server-side (backend) webservice integration differ from frontend integration, and what doe...
In backend integration your webserver calls the external API itself and sends the finished result to the client — the browser never talks to the external service directly.
The difference is who makes the external call. In the frontend model the browser fetches the API directly; i...
Q What steps are involved in building a webservice integration?
Integrating an external webservice follows a predictable arc: understand the API, poke it by hand, then build search → display → error handling around it.
A "webservice integration" means your app pulls live data from someone else's API instead of computing it itself. The trap be...
Q What is an API key, and what do you have to consider when using one?
An API key (sometimes called a token) is a unique string that identifies and authenticates your application to an external API — usually sent as a query parameter or an HTTP header.
You typically get a key by registering with the provider; the key then ties every request back to...
Q How do you call external APIs from Node.js on the server, and how does it compare to fetching in the...
Node.js has the same built-in fetch API as the browser (no import needed since Node v21), so the calling code looks almost identical — the difference is in the request headers that get sent.
async function getStationData(station) {
const url = 'https://transport.opendata.ch/v1/...