Leçon 7 sur 8
Tester les APIs
Avant de connecter une API à une interface, testez-la. Postman fournit une interface graphique. cURL permet de tester depuis le terminal.
Tester directement l’API aide à séparer les problèmes backend des problèmes frontend.
APIS
# Tester avec cURL
curl https://api.example.com/users
# POST avec cURL
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Ali"}'
# Dans Postman :
# 1. Enter the URL
# 2. Choose the HTTP method
# 3. Add headers if needed
# 4. Click Send and see the response