# Error when trying to use the API

**URL:** <https://community.hubspot.com/t/error-when-trying-to-use-the-api/21057>\
**Category:** APIs & Integrations\
**Tags:** timeline-and-extensions-apis\
**Created:** [May 21, 2020, 8:44am UTC](https://community.hubspot.com/t/error-when-trying-to-use-the-api/21057 "2020-05-21T08:44:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexl22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexl22/32/13631_2.png) [@alexl22](https://community.hubspot.com/u/alexl22)\
**Post date:** [May 21, 2020, 8:44am UTC](https://community.hubspot.com/t/error-when-trying-to-use-the-api/21057/1 "2020-05-21T08:44:00Z")

</div>

I followed the Hubspot Academy tutorial for APIs to try and get a simple API call up and running, but I ran into a problem that I couldn’t find answers to.

For context, here is my package.json code:

```auto
{
 "name": "hello_world",
 "version": "1.0.0",
 "main": "index.js",
 "license": "MIT",
 "scripts": {
 "start": "node index.js"
 },
 "dependencies": {
 "express": "^4.16.3",
 "axios": "^0.17.0"
 }
}

```

Along with my index.js code (api key not included, of course):

```auto
const express = require('express');
const axios = require('axios');

const app = express();

const API_KEY = "";

app.get('/contacts', async (req, res) => {
 const contacts = `https://api.hubapi.com/contacts/v1/lists/all/contacts/recent?hapikey=${API_KEY}`;
 try{
 const response = await axios.get(contacts);
 const data = response.data;
 res.json(data);
 }
 catch(err){
 console.error(err);
 }

});

app.listen(3000, () => console.log(`Listening on http://localhost:3000`));

```

After I run ‘npm start’ and go to localhost:3000, my screen still displays

`Cannot GET /`

and in my inspect element console, this is what shows.

 ![27120i66E29F921F2C2EF3.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/5/05080d36102f2901f25bd13aa8c5d9bb94898f59.png)

Could someone help me debug or explain to me what this error is?

Thanks

---

<div class="post-metadata">

**Author:** ![alexl22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexl22/32/13631_2.png) [@alexl22](https://community.hubspot.com/u/alexl22)\
**Post date:** [May 22, 2020, 5:28pm UTC](https://community.hubspot.com/t/error-when-trying-to-use-the-api/21057/2 "2020-05-22T17:28:04Z")

</div>

Bumping because I could really use some help.

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [May 22, 2020, 8:08pm UTC](https://community.hubspot.com/t/error-when-trying-to-use-the-api/21057/3 "2020-05-22T20:08:09Z")

</div>

Hey, @alexl22.

Thanks for reaching out. I’m happy to lend some help.

It looks like you’re expecting the response at `http://localhost:3000`?  
Based on your`index.js` file, though, you’ll have to navigate to `http://localhost:3000/contacts`, since that’s where the endpoint is configured.

Since your `index.js` file is based on Jeff Ausura’s example in the HubSpot Academy [Introduction to the HubSpot APIs](https://academy.hubspot.com/courses/introduction-to-hubspot-apis) course, this step can also be seen in the “Getting Started With HubSpot APIs” lesson’s third video, “Building a hello world app with HubSpot APIs” at approximately **6:44**.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![alexl22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexl22/32/13631_2.png) [@alexl22](https://community.hubspot.com/u/alexl22)\
**Post date:** [May 22, 2020, 8:18pm UTC](https://community.hubspot.com/t/error-when-trying-to-use-the-api/21057/4 "2020-05-22T20:18:11Z")

</div>

Oh my gosh thank you so much Isaac! I can’t believe I completely mislooked that…

I will be sure to reach out if I have any more questions.

Thanks again!

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [May 22, 2020, 9:09pm UTC](https://community.hubspot.com/t/error-when-trying-to-use-the-api/21057/5 "2020-05-22T21:09:40Z")

</div>

You’re welcome, @alexl22!
