Header is not definedProper way to set response status and JSON content in a REST API made with nodejs and expressNode.js express, timeout “Can't set headers after they are sent.”How to Access header in AWS Lambda?Why authorization header returns undefined in each request in MEAN applicationAuthentication with React Native and API backendAngular don't set token in Request HeaderHue API remote Basic AuthenticationNode - passport-http how to return json response if failedSending formData with ReactJS to Express API and taking a responding JSONHow to write Authorization in response's header

A fast aquatic predator with multiple eyes and pupils. Would these eyes be possible?

Why does Chinuch confuse Parashat Nitzavim and Vayelech?

Did smallpox emerge in 1580?

How to print and use a command output in a one-liner?

Does an excessive table violate normalization rules?

How to get the SMILES of all compounds on PubChem?

Why increase or decrease rudder when using elevator in turns?

Is any one against the rational teachings of Maimonides?

What does the British parliament hope to achieve by requesting a third Brexit extension?

How to respond to "Why didn't you do a postdoc after your PhD?"

How to protect my Wi-Fi password from being displayed by Android phones when sharing it with QR code?

Is "of blue" in order to mean "blue" grammatical?

What happens if a geocentric model of the world were correct?

Is Schrodinger's Cat itself an observer?

What is the design rationale for having armor and magic penetration mechanics?

I got this nail stuck in my tire, should I plug or replace?

Trying to add electrical outlets off of a junction box but the junction box has a lot more wires than Ive been shown so which ones to run it off?

Usefulness of Nash embedding theorem

How can a company compel a W2 employee to sign a non-compete agreement?

Incorrect mmap behavior when assembly files in included in the project

Pass a bash variable to python script

Can there be an atomic nucleus where there are more protons than neutrons?

Who is Sifter, and what is "the so-called Sifter flare"?

Is it now possible to undetectably cross the Arctic Ocean on ski/kayak?



Header is not defined


Proper way to set response status and JSON content in a REST API made with nodejs and expressNode.js express, timeout “Can't set headers after they are sent.”How to Access header in AWS Lambda?Why authorization header returns undefined in each request in MEAN applicationAuthentication with React Native and API backendAngular don't set token in Request HeaderHue API remote Basic AuthenticationNode - passport-http how to return json response if failedSending formData with ReactJS to Express API and taking a responding JSONHow to write Authorization in response's header






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









1

















im tryng to send headers on a fetch call on my nodejs express api, but im getting headers is not defined when running this code



module.exports = saveSuverys = (url,user,password) => 
let base64 = require('base-64');
var myHeaders = new Headers();

myHeaders.append('Authorization', 'Basic' + base64.encode(user + ":" + password));

fetch(url, method:'GET',
headers: myHeaders,
)
.then(response => response.json())
.then(json => json);




what im missing?










share|improve this question




























  • where do you import Headers ?

    – Derek Pollard
    Mar 28 at 21:24











  • also, where do you define headers ? You have myHeaders not headers

    – Derek Pollard
    Mar 28 at 21:25











  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20

















1

















im tryng to send headers on a fetch call on my nodejs express api, but im getting headers is not defined when running this code



module.exports = saveSuverys = (url,user,password) => 
let base64 = require('base-64');
var myHeaders = new Headers();

myHeaders.append('Authorization', 'Basic' + base64.encode(user + ":" + password));

fetch(url, method:'GET',
headers: myHeaders,
)
.then(response => response.json())
.then(json => json);




what im missing?










share|improve this question




























  • where do you import Headers ?

    – Derek Pollard
    Mar 28 at 21:24











  • also, where do you define headers ? You have myHeaders not headers

    – Derek Pollard
    Mar 28 at 21:25











  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20













1












1








1








im tryng to send headers on a fetch call on my nodejs express api, but im getting headers is not defined when running this code



module.exports = saveSuverys = (url,user,password) => 
let base64 = require('base-64');
var myHeaders = new Headers();

myHeaders.append('Authorization', 'Basic' + base64.encode(user + ":" + password));

fetch(url, method:'GET',
headers: myHeaders,
)
.then(response => response.json())
.then(json => json);




what im missing?










share|improve this question
















im tryng to send headers on a fetch call on my nodejs express api, but im getting headers is not defined when running this code



module.exports = saveSuverys = (url,user,password) => 
let base64 = require('base-64');
var myHeaders = new Headers();

myHeaders.append('Authorization', 'Basic' + base64.encode(user + ":" + password));

fetch(url, method:'GET',
headers: myHeaders,
)
.then(response => response.json())
.then(json => json);




what im missing?







node.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question



share|improve this question








edited Mar 29 at 10:20







Daniel Bezerra De Menezes

















asked Mar 28 at 21:22









Daniel Bezerra De MenezesDaniel Bezerra De Menezes

5087 silver badges25 bronze badges




5087 silver badges25 bronze badges















  • where do you import Headers ?

    – Derek Pollard
    Mar 28 at 21:24











  • also, where do you define headers ? You have myHeaders not headers

    – Derek Pollard
    Mar 28 at 21:25











  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20

















  • where do you import Headers ?

    – Derek Pollard
    Mar 28 at 21:24











  • also, where do you define headers ? You have myHeaders not headers

    – Derek Pollard
    Mar 28 at 21:25











  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20
















where do you import Headers ?

– Derek Pollard
Mar 28 at 21:24





where do you import Headers ?

– Derek Pollard
Mar 28 at 21:24













also, where do you define headers ? You have myHeaders not headers

– Derek Pollard
Mar 28 at 21:25





also, where do you define headers ? You have myHeaders not headers

– Derek Pollard
Mar 28 at 21:25













edited it, that was not the issue, the headers not defined is refereing to new Headers()

– Daniel Bezerra De Menezes
Mar 29 at 10:20





edited it, that was not the issue, the headers not defined is refereing to new Headers()

– Daniel Bezerra De Menezes
Mar 29 at 10:20












1 Answer
1






active

oldest

votes


















0


















Change headers.append(...); to myHeaders.append(...);.



You're defining a variable named myHeaders, not headers.



Also, check if you're loading the module via require, like const fetch = require('node-fetch');.






share|improve this answer




























  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20











  • @DanielBezerraDeMenezes I edited the answer, let me know if it solves your problem.

    – Diogo Rocha
    Mar 29 at 11:08












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407045%2fheader-is-not-defined%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown


























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0


















Change headers.append(...); to myHeaders.append(...);.



You're defining a variable named myHeaders, not headers.



Also, check if you're loading the module via require, like const fetch = require('node-fetch');.






share|improve this answer




























  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20











  • @DanielBezerraDeMenezes I edited the answer, let me know if it solves your problem.

    – Diogo Rocha
    Mar 29 at 11:08















0


















Change headers.append(...); to myHeaders.append(...);.



You're defining a variable named myHeaders, not headers.



Also, check if you're loading the module via require, like const fetch = require('node-fetch');.






share|improve this answer




























  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20











  • @DanielBezerraDeMenezes I edited the answer, let me know if it solves your problem.

    – Diogo Rocha
    Mar 29 at 11:08













0














0










0









Change headers.append(...); to myHeaders.append(...);.



You're defining a variable named myHeaders, not headers.



Also, check if you're loading the module via require, like const fetch = require('node-fetch');.






share|improve this answer
















Change headers.append(...); to myHeaders.append(...);.



You're defining a variable named myHeaders, not headers.



Also, check if you're loading the module via require, like const fetch = require('node-fetch');.







share|improve this answer















share|improve this answer




share|improve this answer



share|improve this answer








edited Mar 29 at 11:07

























answered Mar 28 at 21:27









Diogo RochaDiogo Rocha

2,2991 gold badge23 silver badges28 bronze badges




2,2991 gold badge23 silver badges28 bronze badges















  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20











  • @DanielBezerraDeMenezes I edited the answer, let me know if it solves your problem.

    – Diogo Rocha
    Mar 29 at 11:08

















  • edited it, that was not the issue, the headers not defined is refereing to new Headers()

    – Daniel Bezerra De Menezes
    Mar 29 at 10:20











  • @DanielBezerraDeMenezes I edited the answer, let me know if it solves your problem.

    – Diogo Rocha
    Mar 29 at 11:08
















edited it, that was not the issue, the headers not defined is refereing to new Headers()

– Daniel Bezerra De Menezes
Mar 29 at 10:20





edited it, that was not the issue, the headers not defined is refereing to new Headers()

– Daniel Bezerra De Menezes
Mar 29 at 10:20













@DanielBezerraDeMenezes I edited the answer, let me know if it solves your problem.

– Diogo Rocha
Mar 29 at 11:08





@DanielBezerraDeMenezes I edited the answer, let me know if it solves your problem.

– Diogo Rocha
Mar 29 at 11:08




















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55407045%2fheader-is-not-defined%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown









Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript