I need to pass data through headers, to consume an api #16737
Unanswered
rafael-legyo
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I need to pass data through headers, to consume an api.
Can I use axios to do this?
const api = axios.create({
baseURL: "http://127.0.0.1:3333",
});
export async function getStaticProps() {
const { data } = await api.get("/produtos-pacotes", {
headers: {
initialsproduct: "age",
},
});
console.log(data);
return {
props: {
data,
},
revalidate: 1,
};
}
Locally it worked as I expected. But everything is very new to me in Nextjs.
Here it says it is now possible to pass - https://nextjs.org/blog/next-9-5#headers
But here it doesn't tell me how to use it - https://nextjs.org/docs/api-reference/next.config.js/headers
Beta Was this translation helpful? Give feedback.
All reactions