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;
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
add a comment
|
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
where do you importHeaders
?
– Derek Pollard
Mar 28 at 21:24
also, where do you defineheaders
? You havemyHeaders
notheaders
– 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
add a comment
|
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
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
node.js
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 importHeaders
?
– Derek Pollard
Mar 28 at 21:24
also, where do you defineheaders
? You havemyHeaders
notheaders
– 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
add a comment
|
where do you importHeaders
?
– Derek Pollard
Mar 28 at 21:24
also, where do you defineheaders
? You havemyHeaders
notheaders
– 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
add a comment
|
1 Answer
1
active
oldest
votes
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');
.
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
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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');
.
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
add a comment
|
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');
.
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
add a comment
|
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');
.
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');
.
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
add a comment
|
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
add a comment
|
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
where do you import
Headers
?– Derek Pollard
Mar 28 at 21:24
also, where do you define
headers
? You havemyHeaders
notheaders
– 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