0

This is probably going to be an easy one but I am hitting a wall. What I am hitting to do is hit an endpoint using a GET Request and then pretty print that data to the console. Originally I was thinking I should be using app.get('/'); as this is how I did the Hello World and also the same when I build out a simple endpoint 'api/contacts'. My overall goal is just to GET the data from this endpoint and then use it for a post request. But now I believe I should be using app.use instead.

'use strict';
const access_token = "";
const express = require('express');
var bodyParser = require('body-parser')
const app = express();

app.use(bodyParser.json());

app.use('https://api.hubapi.com/content/api/v2/blog-posts?
limit=1000&hapikey=' + access_token, (req, res) => {
});

Now my thinking from Node I feel like I should be able to use the below. Also I feel like I should also be using res.send and this is not working.

console.log('STATUS: ' + response.statusCode);
console.log('HEADERS: ' + JSON.stringify(response.headers));

1 Answer 1

1

Express is for handling and responding to requests made to the server. You are trying to make a request to another server. You should look into the request lib.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.