node:internal/errors:464 ErrorCaptureStackTrace(err);

Viewed 3603

When I was trying to add secure api keys in the .env file, I got this error.

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "X-RapidAPI-Host"
    at ClientRequest.setHeader (node:_http_outgoing:579:3)
    at new ClientRequest (node:_http_client:256:14)
    at Object.request (node:https:353:10)

Below are my codes:

const axios = require("axios");

const BASE_URL = `https://mashape-community-urban-dictionary.p.rapidapi.com`

module.exports = {
    getCompatibility: (yourSearch) => axios({
        method:"GET",
        url : BASE_URL + `/define`,
        headers: {
          'X-RapidAPI-Host': process.env.rapidapi_host,
          'X-RapidAPI-Key': process.env.Rrapidapi_key
        },
        params: {
            term: yourSearch
        }
    })
}

My env file:

rapidapi_host={my secure host}
rapidapi_key={my secure key}

Can anyone explain why that is happening?

1 Answers

This error means that the value of the X-RapidAPI-Host header you are passing is empty.

Check whether you are properly setting the rapidapi_host environment variable for the process.

Related