Created
May 22, 2024 15:58
-
-
Save mekarpeles/0d308bfd8e75858d2266b8aa983cac07 to your computer and use it in GitHub Desktop.
js example of adding app identification headers to openlibrary.org API calls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@katusiimeconrad Wow man, many thanks!