Skip to content

Instantly share code, notes, and snippets.

@mekarpeles
Created May 22, 2024 15:58
Show Gist options
  • Save mekarpeles/0d308bfd8e75858d2266b8aa983cac07 to your computer and use it in GitHub Desktop.
Save mekarpeles/0d308bfd8e75858d2266b8aa983cac07 to your computer and use it in GitHub Desktop.
js example of adding app identification headers to openlibrary.org API calls
const url = "https://openlibrary.org/search.json?q=test";
const headers = new Headers({
"User-Agent": "MyAppName/1.0 ([email protected])"
});
const options = {
method: 'GET',
headers: headers
};
fetch(url, options)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
@LyudmilC-dacc-939
Copy link

@katusiimeconrad Wow man, many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment