If you’re learning how to send data to api in javascript node, start with `fetch` (Node 18+)—it’s standardized and works in browsers too.
For errors, always check:
1. Is the URL correct?
2. Are headers set (like `Content-Type`)?
3. Is the server actually up?
```javascript
const res = await fetch(API_URL, options);
if (!res.ok) {
const error = await res.text();
throw new Error(error);
}
```
For errors, always check:
1. Is the URL correct?
2. Are headers set (like `Content-Type`)?
3. Is the server actually up?
```javascript
const res = await fetch(API_URL, options);
if (!res.ok) {
const error = await res.text();
throw new Error(error);
}
```
