APIs & Integrations

AChong
Member

Axios without Depracated Request Library

Hello - Saw "Request" library is depracated, and the Hubspot package depends on it, so I wanted to see how to make an axios request server side to get a contact without either library. I'm using the following code, but getting a 401 response. 

 

import express from 'express';
import axios from 'axios';
const app = express();
const accessToken = 'my still valid access token was here - assume it came from the same domain.'

app.get('/', (reqres)=>{
        headers:{
          'Content_Type''application/json',
          'Authorization'`Bearer ${accessToken}`}})
      .then(response=>{
        // handle success
        res.send(response.data)
      })
      .catch(err => res.send(err));
    })

app.listen(3005);
 
Any idea what I could be missing here? 
0 Upvotes
3 Replies 3
dennisedson
HubSpot Product Team
HubSpot Product Team

Axios without Depracated Request Library

FYI, the team is looking into this now.  Keep an 👀 on that repo!

0 Upvotes
kierana
Contributor

Axios without Depracated Request Library

I would recommend still using the library. I imagine the Hubspot team will eventually change it over. Is your application requesting the correct scopes/permissions for this endpoint?

 

 

dennisedson
HubSpot Product Team
HubSpot Product Team

Axios without Depracated Request Library

Hey @AChong 

First of all, I have asked internally if this is deprecated dependency is going to be replaced.

Secondly, I am hoping that @kierana has some insight into this axios issue. 🙏

0 Upvotes