Just dipping my toes into the world of API's and still struggling with JS/Ajax. Apologies if this question sounds silly.
I have managed to make the following code work, which I sourced from the developers documentation and made a few tweaks:
var token = getParameterByName('access_token');
$.ajax({
url: "https://api.myapp.de/api/v2/users/me",
type: "GET",
beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'bearer ' + token);},
success: function(data) {
console.log(data);
}
});
This script successfully retrieves my user information and displays it in the console.
Now, I am working on creating a web app (to improve my coding skills) that requires updating information using the PATCH method. How can I achieve this with Ajax?
I specifically need to update the following information in the JSON file: "id": "idIwantToUpdate", "ringNumber": 4. I've searched extensively online and came across some resources that might have the solution (e.g., https://www.rfc-editor.org/rfc/rfc7396), but they seem overly complex for me to grasp. After spending hours on this without much progress, is there anyone who can explain it in simpler terms? Appreciate any help!