<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: puzzle29</title>
    <description>The latest articles on DEV Community by puzzle29 (@puzzle29).</description>
    <link>https://dev.to/puzzle29</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F363506%2F1ca0ab8f-1ddf-4aea-9371-7b06927d12d3.png</url>
      <title>DEV Community: puzzle29</title>
      <link>https://dev.to/puzzle29</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/puzzle29"/>
    <language>en</language>
    <item>
      <title>Problem with axios header in nuxt.js</title>
      <dc:creator>puzzle29</dc:creator>
      <pubDate>Sat, 01 Jul 2023 18:57:08 +0000</pubDate>
      <link>https://dev.to/puzzle29/problem-with-axios-header-in-nuxtjs-kpo</link>
      <guid>https://dev.to/puzzle29/problem-with-axios-header-in-nuxtjs-kpo</guid>
      <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I'm working on a project using nuxt.js that other developers have already worked on.&lt;br&gt;
I don't know much about nuxt.js and I'm having a problem that I can't solve.&lt;br&gt;
When I do an &lt;code&gt;npm run build&lt;/code&gt; then &lt;code&gt;npm run start&lt;/code&gt; the application works normally, but when I do an &lt;code&gt;npm run dev&lt;/code&gt; I get errors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: Cannot read properties of undefined (reading 'Authorization')                         
TypeError: Cannot read properties of undefined (reading 'status')                                

 ERROR  Cannot read properties of undefined (reading 'status')                                           

  at server.js:13024:24
  at server.js:455:56
  at async asyncData (pages/landing/students.js:2156:35)
  at async Promise.all (index 0)
  at async Promise.all (index 0)
  at async module.exports../.nuxt/server.js.__webpack_exports__.default (server.js:5494:22)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moreover if I remove the &lt;code&gt;headers&lt;/code&gt; from the axios requests, there is no more error and the application works when I do &lt;code&gt;npm run dev&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is a portion of the code that is causing the problem :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async asyncData({app, params, $axios, $config: { baseURL } }) {
        const res = await $axios.$get(`/api/student`, {
            headers: {
              'Accept-Language': app.i18n.locale,
            },
        })
        .then((res) =&amp;gt; {
          console.log(res)
          return res
        })
        .catch((err) =&amp;gt; {
          console.error(err)
        });

        return { res }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>vue</category>
      <category>nuxt</category>
      <category>axios</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
