obtaining user information from API using the x-api-key

As a beginner JavaScript programmer, I'm attempting to fetch user information. Is there a simple way to search for a specific person like Laurel Gates with the USERID: 987654321? English is not my native language, so I apologize for any mistakes. Here is the code I'm using:

<!DOCTYPE html>
<html lang="en>
<head>
    <meta charset="UTF-8">
    <title>Retrieve</title>
    <meta name="viewport" content="width=device-width">
    <style>
    </style>
</head>
<body>

    <script>
       fetch("https://*******.****-.com/",{
        method:"GET",
        headers:{
                 "Content-type": "application/json",
                 "X-API-Key": "o************************G" 
    }
})
    .then( function(response) {
        if(response.ok){
            return response.json();
        }
    })
    .then( function(data) {
        console.log(data);
    })
    .catch( function(error) {
        console.log('ERROR: ', error.message);
    }); 
    </script>

</body>
</html>

Answer №1

Following a discussion through chat, it was determined that the issue stemmed from the Content-Response, which was missing a property that was being called by console.log.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The C# method is receiving a null array through Ajax

When I retrieve an array in a loop and pass it through an ajax call to my C# method, I'm encountering a problem where only null values are being received in my parameter. The count of the array is coming through, but the actual data seems to be lost. ...

Top-align the background of the inline element

This particular inquiry pertains to a curious discrepancy in the computed height of an inline nonreplaced element across different web browsers. The question can be found here: Why the computed height of inline nonreplaced element differs between browsers? ...

ways to undo modifications made to a value within an input field using jquery or javascript

$(document).ready(function () { //Highlight row when selected. $(function () { $('#Cases tr').click(function () { $('#Cases tr').removeClass('selectedRow'); $(this).addClass(&apos ...

What is the technique used by express.js to handle ReferenceError?

// Here is a sample code snippet app.get("/test", (req, res) => { return res.status(200).send(SOME_UNDEFINED_VAR); }); If a ReferenceError occurs, express.js will automatically send a 500 error response. express.js logs the ReferenceError to std ...

A guide to incorporating nested loops with the map method in React JS

I've come across numerous threads addressing the nested loop using map in React JS issue, but I'm still struggling to implement it in my code. Despite multiple attempts, I keep encountering errors. Here are some topics I've explored but cou ...

Unlocking the Potential of Checkbox Values in AngularJS

I am attempting to extract data from a $rootScope object that has been linked to the checkboxes. HTML: <tr ng-repeat="system_history in SystemHistoryResponse.system_history"> <td><input type="checkbox" ng-model="versionValues[system_histor ...

Import and Showcase Collada Models with Textures using Three.js and file inputs

Currently, I am faced with a challenge involving loading a Collada file along with textures from file inputs. Specifically, I have set up 2 inputs, one for the geometry (.dae) file, and another for textures (.png/.jpg). When these file inputs change, two s ...

Checking phone number on a React.js form

I am currently working on a front-end application and need to implement form validation. I am relatively new to ReactJS and learning as I go along in the development process. One of the input fields requires a phone number, which should only accept number ...

The hamburger menu is only functional for a single link

I've been developing a hamburger menu for my website, and it seems to be working fine until I click on a link. Once I navigate to a new page, the menu stops responding. To fix this issue, I attempted to use window.location.reload, which worked in Chro ...

Ways to switch out the background image using jQuery

I am currently using jQuery to dynamically change the background image of a web page. Right now, I have implemented two separate buttons that toggle between Image A and Image B. By default, Image A is displayed on the page. My goal is to enhance this func ...

When I try to import script files into my ASP.NET page, Intellisense displays the methods accurately. However, when I attempt to call one of them, an

I added a function to an existing .js file (I tried two different files) in order to make the method accessible in multiple locations without having to repeat the code. I also created a simple function just to confirm that my function wasn't causing a ...

Solving complex promises in both serial and parallel fashion

My current function performs four tasks that must be executed in a specific sequence: - promise1 - promiseAfter1 // In parallel - promise2 - promiseAfter2 To ensure the promises are handled sequentially, I have structured two separate functions as follows ...

Is there a way to make two parallelograms overlap seamlessly and adjust in size automatically using HTML?

Recently delving into the world of HTML and CSS, I've set my sights on designing something unique involving parallelograms that adjust dynamically. My vision includes four overlapping parallelograms starting from the top at 25%, 50%, 75%, and finally ...

The protractor-jasmine2-html-reporter fails to generate an HTML report

In my protractor config.js, I have set up the configuration to generate screenshots in a specific folder, but the HTML report is not being generated. I have followed the steps mentioned in this guide: https://www.npmjs.com/package/protractor-jasmine2-htm ...

Utilizing 'document.execCommand' for handling 'delete' key events in AngularJS

Here is a demo plunkr link that I have created to demonstrate the issue. I am looking to implement the strikeThrough command whenever there is a delete operation. For instance: If the user selects "Text" and presses the delete or backspace key, it should ...

When I attempted to run `npm start`, an error with status code 1 was thrown,

Upon running npm start, the following error is displayed: > <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d4c5d5d6d1d031c031d">[email protected]</a> start /Users/user/Desktop/react-tutorial > react-script ...

Fill the second dropdown menu options based on the selection made in the first dropdown menu

I need assistance with dynamically populating my second drop-down menu based on the selection made in the first drop-down. Here are the steps I've taken so far: form.php - Utilizing javascript, I have set up a function to call getgeneral.php. The se ...

ES6 scoping confusion: unraveling the mystery

I stumbled upon these two syntax methods for exporting functions. Let's say we have files named actions.js and app.js. The first method looks like this: in actions.js export function addTodo() {} export function deleteTodo() {} and in app.js I have ...

Font modification is unsuccessful in Vue-Material

Here is a snippet from my App.vue file where I encountered an issue with changing the font in the md-tabs component, taken from . The CSS line: background: #42A5F5; works perfectly fine, but this one does not: color: #E3F2FD; App.vue: <template> ...

Include previous input as a "phantom" thumbnail to the slider element of type "range"

https://i.stack.imgur.com/JnuCN.png Using a tutorial from w3schools, I have customized a regular range slider. The objective is to send a new value command to an external MQTT-based home automation system and display the previous value as a ghost-thumb in ...