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 (myemail@example.com)" | |
}); | |
const options = { | |
method: 'GET', | |
headers: headers | |
}; | |
fetch(url, options) | |
.then(response => response.json()) | |
.then(data => console.log(data)) | |
.catch(error => console.error('Error:', error)); |
It's a network request so you should be able to adapt this to any language.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I wrote an email to sapphire regarding a small inconvenience I'm having, is there any chance you CAN write such form for Java(I need it for a personal project that is going to make real requests/calls to your APIs)? It's quite a primitive Java code that I have to use public API and wanted to use this one.