Following https://gerrit.wikimedia.org/r/693506, the API Gateway now supports Api-User-Agent headers in JavaScript requests. In the API Portal, add an Api-User-Agent header to all JavaScript examples.
For example, on API_reference/Core/Search/Search_content, change:
// Search English Wikipedia for 10 articles about Earth let url = 'https://api.wikimedia.org/core/v1/wikipedia/en/search/page?q=earth&limit=10'; let response = await fetch( url, { headers: { 'Authorization': 'Bearer YOUR_ACCESS_TOKEN' } } ); response.json() .then(console.log).catch(console.error);
to
// Search English Wikipedia for 10 articles about Earth let url = 'https://api.wikimedia.org/core/v1/wikipedia/en/search/page?q=earth&limit=10'; let response = await fetch( url, { headers: { 'Authorization': 'Bearer YOUR_ACCESS_TOKEN', 'Api-User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)' } } ); response.json() .then(console.log).catch(console.error);