<?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: Sai Avinash Duddupudi</title>
    <description>The latest articles on DEV Community by Sai Avinash Duddupudi (@saiavinashiitr).</description>
    <link>https://dev.to/saiavinashiitr</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%2F460011%2F954f53df-d77d-462d-944c-b9c0580b3743.jpeg</url>
      <title>DEV Community: Sai Avinash Duddupudi</title>
      <link>https://dev.to/saiavinashiitr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saiavinashiitr"/>
    <language>en</language>
    <item>
      <title>Python requests_html is throwing error There is no current event loop in thread 'ThreadPoolExecutor-0_0'</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Fri, 04 Jun 2021 13:40:20 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/python-requestshtml-throwing-error-there-is-no-current-event-loop-in-thread-threadpoolexecutor-00-2gl8</link>
      <guid>https://dev.to/saiavinashiitr/python-requestshtml-throwing-error-there-is-no-current-event-loop-in-thread-threadpoolexecutor-00-2gl8</guid>
      <description>&lt;p&gt;I am trying to run a &lt;code&gt;JS script&lt;/code&gt; using &lt;strong&gt;python requests_html module&lt;/strong&gt; for a given url but was getting few errors. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can some please help me out where I am doing wrong?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code&lt;/strong&gt; :- &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from requests_html import HTMLSession
def rrr(request):
    session = HTMLSession()
    url = 'https://careers.microsoft.com/'
    response = session.get(url)
    script = """
                () =&amp;gt; {
                    return {
                        ans: window.location.href,
                    }
                }
            """
    ans = response.html.render(script=script)
    return JsonResponse(ans, safe=False)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Error :-&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  File "/home/mahesh/anaconda3/lib/python3.7/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/home/mahesh/anaconda3/lib/python3.7/site-packages/rest_framework/views.py", line 502, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/mahesh/anaconda3/lib/python3.7/site-packages/rest_framework/decorators.py", line 50, in handler
    return func(*args, **kwargs)
  File "/home/mahesh/Documents/dojo/dojo/dojo/tenants/api.py", line 242, in rrr
    ans = response.html.render(script=script)
  File "/home/mahesh/anaconda3/lib/python3.7/site-packages/requests_html.py", line 586, in render
    self.browser = self.session.browser  # Automatically create a event loop and browser
  File "/home/mahesh/anaconda3/lib/python3.7/site-packages/requests_html.py", line 727, in browser
    self.loop = asyncio.get_event_loop()
  File "/home/mahesh/anaconda3/lib/python3.7/asyncio/events.py", line 644, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'ThreadPoolExecutor-0_0'.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;When ran in terminal, it worked fine as follows&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.stack.imgur.com/gb1M3.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N6d7DmB6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.stack.imgur.com/gb1M3.png" alt="enter image description here"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>django</category>
    </item>
    <item>
      <title>Cannot launch puppeteer browser instance in docker image</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Thu, 22 Apr 2021 20:38:03 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/cannot-launch-puppeteer-browser-instance-in-docker-image-2d07</link>
      <guid>https://dev.to/saiavinashiitr/cannot-launch-puppeteer-browser-instance-in-docker-image-2d07</guid>
      <description>&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;I am trying a launch a headless chrome and perform some actions using puppeteer in my Nodejs code. &lt;/p&gt;

&lt;p&gt;This works great(with &lt;code&gt;npm start&lt;/code&gt;) but when I try to build Docker image from Docker file and run the image and execute the function, I get the following error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(node:18) UnhandledPromiseRejectionWarning: Error: Unable to launch browser, error message: Failed to launch the browser process!
[0422/194052.772673:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, after some search, I found that adding &lt;code&gt;args: ["--no-sandbox"]&lt;/code&gt; during browser launch will solve the problem but still the same error keeps coming.&lt;/p&gt;

&lt;p&gt;Here is my Dockerfile. &lt;br&gt;
&lt;a href="https://slack-files.com/T04MYU6C6-F01V3C7NQTX-6b82740d91"&gt;https://slack-files.com/T04MYU6C6-F01V3C7NQTX-6b82740d91&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please suggest a workaround&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>devops</category>
    </item>
    <item>
      <title>Unable to fix Antd Modal Height</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Thu, 18 Feb 2021 22:36:18 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/unable-to-fix-antd-modal-height-4lha</link>
      <guid>https://dev.to/saiavinashiitr/unable-to-fix-antd-modal-height-4lha</guid>
      <description>&lt;p&gt;I am trying to set &lt;strong&gt;Antd Modal height to 1000px by default&lt;/strong&gt; but its &lt;strong&gt;not getting applied&lt;/strong&gt;. Please suggest where I might be doing wrong. Below is my code for the Modal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Modal style={{ height: "1000px" }} className="pm" width={600} title="Select" visible={isModalVisible3} footer={null} onCancel={() =&amp;gt;setIsModalVisible3(false)}&amp;gt;
    &amp;lt;span&amp;gt;Sample Text&amp;lt;/span&amp;gt;
&amp;lt;/Modal&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I even added &lt;code&gt;.pm{height: 1000px;}&lt;/code&gt; in my &lt;strong&gt;base.css&lt;/strong&gt; file but no luck&lt;/p&gt;

&lt;p&gt;Please suggest a workaround.&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>Property 'maxCount' does not exist on type 'IntrinsicAttributes</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Fri, 29 Jan 2021 15:36:15 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/property-maxcount-does-not-exist-on-type-intrinsicattributes-4p50</link>
      <guid>https://dev.to/saiavinashiitr/property-maxcount-does-not-exist-on-type-intrinsicattributes-4p50</guid>
      <description>&lt;p&gt;I am trying to implement antd upload button functionality in tsx file but for some reason I am getting the &lt;strong&gt;following Typescript error&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;I have also created an interface for the same but no luck. Please suggest me where I am doing it wrong. Thanks&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Type '{ children: Element; maxCount: number; }' is not assignable to type 'IntrinsicAttributes &amp;amp; UploadProps&amp;lt;any&amp;gt; &amp;amp; { children?: ReactNode; } &amp;amp; RefAttributes&amp;lt;any&amp;gt;'.
      Property 'maxCount' does not exist on type 'IntrinsicAttributes &amp;amp; UploadProps&amp;lt;any&amp;gt; &amp;amp; { children?: ReactNode; } &amp;amp; RefAttributes&amp;lt;any&amp;gt;'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here is the code&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface IMyProps {
    maxCount: number,
    }

const AdminPage: React.FC&amp;lt;IMyProps&amp;gt; = ({maxCount}) =&amp;gt; {
      const [isModalVisible, setIsModalVisible] = useState(false);

        const onFinish = (values:any) =&amp;gt; {
          console.log(values)
         };
        return (
            &amp;lt;React.Fragment&amp;gt;
            &amp;lt;div&amp;gt;
                &amp;lt;Modal title="Create" visible={isModalVisible} footer={null} onCancel={()=&amp;gt;setIsModalVisible(false)}&amp;gt;
                    &amp;lt;Form layout="vertical" onFinish={onFinish}&amp;gt;
                        &amp;lt;Form.Item label="Upload" name="uploading" &amp;gt;
                            &amp;lt;Upload  maxCount={1}&amp;gt; &amp;lt;---------------- GETTING ERROR HERE
                                &amp;lt;Button icon={&amp;lt;UploadOutlined /&amp;gt;}&amp;gt;Click to Upload&amp;lt;/Button&amp;gt;
                            &amp;lt;/Upload&amp;gt;
                        &amp;lt;/Form.Item&amp;gt;
                        &amp;lt;Form.Item&amp;gt;
                            &amp;lt;Button type="primary" htmlType="submit"&amp;gt;
                                Submit
                            &amp;lt;/Button&amp;gt;
                            &amp;lt;/Form.Item&amp;gt;
                    &amp;lt;/Form&amp;gt;
                &amp;lt;/Modal&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/React.Fragment&amp;gt;
          )
    }

    export default AdminPage;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>react</category>
      <category>typescript</category>
    </item>
    <item>
      <title>saga fetch || Invalid boundary in multipart during uploading files</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Tue, 26 Jan 2021 18:46:35 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/saga-fetch-invalid-boundary-in-multipart-during-uploading-files-3pa5</link>
      <guid>https://dev.to/saiavinashiitr/saga-fetch-invalid-boundary-in-multipart-during-uploading-files-3pa5</guid>
      <description>&lt;p&gt;I am trying to &lt;strong&gt;upload a file and send it to the backend API&lt;/strong&gt; in saga worker but for some reason, the file is not getting fetched at the API side.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Invalid boundary in multipart: None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is the error (&lt;a href="https://i.stack.imgur.com/dwkPR.png"&gt;https://i.stack.imgur.com/dwkPR.png&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Through POSTMAN, able to get the files and it's working fine. all the uploaded files are captured in &lt;code&gt;fileList&lt;/code&gt; and I am capturing only the first file by doing &lt;code&gt;action.data.uploading.fileList[0]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Please suggest where I am doing wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React component&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Ticket = () =&amp;gt; {

        const [isModalVisible, setIsModalVisible] = useState(false);
        const dispatch = useDispatch();

        const onFinish = (values) =&amp;gt; {
          console.log(values)
          console.log(values['uploading']['fileList'])
          dispatch(getUser(values));
         };
        return (
            &amp;lt;React.Fragment&amp;gt;
            &amp;lt;div className="top-section"&amp;gt;
             asd
             &amp;lt;Button type="primary" style={{ float: 'right' }} onClick={()=&amp;gt;setIsModalVisible(true)}&amp;gt;Create Test Suite&amp;lt;/Button&amp;gt;
             &amp;lt;Modal title="Create" visible={isModalVisible} footer={null} onCancel={()=&amp;gt;setIsModalVisible(false)}&amp;gt;
                    &amp;lt;Form layout="vertical" onFinish={onFinish}&amp;gt;
                        &amp;lt;Form.Item label="Upload" name="uploading"&amp;gt;
                          &amp;lt;Upload&amp;gt;
                              &amp;lt;Button icon={&amp;lt;UploadOutlined /&amp;gt;}&amp;gt;Click to Upload&amp;lt;/Button&amp;gt;
                          &amp;lt;/Upload&amp;gt;
                        &amp;lt;/Form.Item&amp;gt;
                        &amp;lt;Form.Item&amp;gt;
                            &amp;lt;Button type="primary" htmlType="submit"&amp;gt;
                              Submit
                            &amp;lt;/Button&amp;gt;
                          &amp;lt;/Form.Item&amp;gt;
                    &amp;lt;/Form&amp;gt;
              &amp;lt;/Modal&amp;gt;
            &amp;lt;/div&amp;gt;
          &amp;lt;/React.Fragment&amp;gt;
          )
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Saga Code&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function* handleGetUser(action) {
        try {
            debugger
            var formdata = new FormData();
            formdata.append("file_name", action.data.uploading.fileList[0]);
            const customer_fetch = yield call(fetch,
                'http://localhost:8000/api',
                {
                    method: "POST",
                    headers: {'Content-Type' : 'multipart/form-data',},
                    body : formdata
                });
        } catch (error) {
            console.log(error);
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
    </item>
    <item>
      <title>POST request in redux-saga not working</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Thu, 21 Jan 2021 09:39:45 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/post-request-in-redux-saga-not-working-11hp</link>
      <guid>https://dev.to/saiavinashiitr/post-request-in-redux-saga-not-working-11hp</guid>
      <description>&lt;p&gt;I would like to make post request in &lt;code&gt;redux-saga&lt;/code&gt;. My code looks like:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var formdata = new FormData();
    formdata.append("points", "a,b");
    formdata.append("pid", "someid");
    formdata.append("tions", "cses");
    formdata.append("exp", "cx");
const ans = yield call(fetch,
'http://localhost:8000/api',
{
    method: "POST",
    headers: { 'Authorization': 'Token tokenid',
                "Content-Type": "application/json",},
    body : formdata
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;In Postman it is working fine(selected &lt;code&gt;form-data&lt;/code&gt; in body)&lt;/strong&gt; but in saga, the POST request is giving error as &lt;code&gt;the server responded with a status of 400 (Bad Request)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Please suggest where I am doing wrong as the API is working fine and all the parameters are correct?&lt;/p&gt;

</description>
      <category>react</category>
      <category>redux</category>
    </item>
    <item>
      <title>Fetch in react js returns 401 (unauthorized) while passing access token</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Wed, 23 Dec 2020 17:53:53 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/fetch-in-react-js-returns-401-unauthorized-while-passing-access-token-17f</link>
      <guid>https://dev.to/saiavinashiitr/fetch-in-react-js-returns-401-unauthorized-while-passing-access-token-17f</guid>
      <description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;I am trying to pass access token to an API that returns data through &lt;code&gt;fetch&lt;/code&gt; from &lt;strong&gt;DATA_API&lt;/strong&gt; but I am getting &lt;code&gt;401 unauthorized error&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;When I opened &lt;code&gt;Network&lt;/code&gt; Tab, I observed that the &lt;code&gt;auth headers did not injected&lt;/code&gt; and hence the 401 error is coming. The token is also getting fetched from &lt;strong&gt;ACCESS_TOKEN_API&lt;/strong&gt; and its getting logged in the console.&lt;/p&gt;

&lt;p&gt;Here is my code. Please suggest a workaround.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState, useEffect } from "react";
import {Col } from 'antd';
import { Link } from "react-router-dom";
import AntDTable from '../shared/AntDTable';
import iInnerLoader from '../shared/iInnerLoader';
const columns = [
  {
    title: 'Account Name',
    dataIndex: 'name',
    render: (text, record) =&amp;gt; (
      &amp;lt;Link to={`/all-customers/tenants/?tenant_id=${record.id}&amp;amp;customer=${record.name}`}&amp;gt;{record.name.toUpperCase()}&amp;lt;/Link&amp;gt;
    ),
  },
  {
    title: 'Total Tenants',
    dataIndex: 'tenantCount',
  }
];
const useFetch = (url, headers) =&amp;gt; {
  const [data, setData] = useState([]);
  const [loading, setLoading] = useState(true);
    useEffect(async () =&amp;gt; {
      const response = await fetch(url,headers)
      const data = await response.json()
      // console.log(data)
      setData(data)
      setLoading(false)
    },[]);
    return {data, loading};
}
​
export default function CreateTestcaseStep2() {
  const [token, setToken] = useState([]);
    useEffect(async () =&amp;gt; {
      const response = await fetch('ACCESS_TOKEN_API',{
        method : 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/x-www-form-urlencoded'
        },
        body : 'body_part'
      })
      const data = await response.json()
      // console.log(data)
      setToken(data)
    },[]);

console.log("token is ", token.access_token) // TOKEN IS GETTING PRINTED HERE
var api_headers={ method: 'GET',
  headers: {'Authorization': `Bearer ${token.access_token}`,
  "Access-Control-Allow-Origin" : "*", 
  "Access-Control-Allow-Credentials" : true },
}
console.log("headers ", api_headers)
  const {data, loading} = useFetch('DATA_API', api_headers)
  return (
    &amp;lt;&amp;gt;
      &amp;lt;Col md={24} sm={24} className="p-0"&amp;gt;
        &amp;lt;div className="customer-list"&amp;gt;
            &amp;lt;div className="customer-list-header"&amp;gt;
              Customer Accounts
            &amp;lt;/div&amp;gt;
            &amp;lt;br/&amp;gt;
            &amp;lt;div className="customer-list-content"&amp;gt;
            {loading? &amp;lt;iInnerLoader isDisplayLabel={true} label={"Loading Customers"} /&amp;gt; :
             &amp;lt;AntDTable columns={columns} data={data.data} pagination={true} height={390}/&amp;gt;}
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/Col&amp;gt;
    &amp;lt;/&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Unable to pass access_token to endpoint in Reactjs</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Wed, 23 Dec 2020 10:25:50 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/unable-to-pass-accesstoken-to-endpoint-in-reactjs-o00</link>
      <guid>https://dev.to/saiavinashiitr/unable-to-pass-accesstoken-to-endpoint-in-reactjs-o00</guid>
      <description>&lt;p&gt;I am trying to fetch data from an API which requires &lt;code&gt;access_token&lt;/code&gt;. There is another API for fetching &lt;code&gt;access_token&lt;/code&gt;. So, I am first trying to fetch acess_token and then pass it to the API which returns data. &lt;/p&gt;

&lt;p&gt;I observed that the token API is getting hit but by the time it is passed to the data API, token is &lt;code&gt;undefined&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.stack.imgur.com/tNPIj.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YRILmaBS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.stack.imgur.com/tNPIj.png" alt="enter image description here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here is my code&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const useFetch = (url, headers) =&amp;gt; {
    const [data, setData] = useState([]);
    const [loading, setLoading] = useState(true);
      useEffect(async () =&amp;gt; {
        const response = await fetch(url, headers)
        const data = await response.json()
        console.log(data)
        setData(data)
        setLoading(false)
      },[]);
      return {data, loading};
  }
export default function CreateTestcaseStep2() {
    var access_token_headers={
        method : 'POST',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/x-www-form-urlencoded'
        },
        body : 'grant_type=something&amp;amp;client_id=something-test&amp;amp;client_secret=something&amp;amp;scope=something'
      }
    const {token, loading_token} = useFetch('ACCESS_TOKEN_API', access_token_headers)
    console.log("token is ", token) // TOKEN IS PRINTED AS UNDEFINED HERE
    var api_headers={ method: 'GET',
      headers: {'Authorization': `Bearer ${token.access_token}`},
    }
    const {data, loading} = useFetch('DATA_API', api_headers)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Please suggest how to get access_token first and then pass it to data_api.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>setState in Reactjs is not a function</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Tue, 22 Dec 2020 17:32:22 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/setstate-in-reactjs-is-not-a-function-3fi4</link>
      <guid>https://dev.to/saiavinashiitr/setstate-in-reactjs-is-not-a-function-3fi4</guid>
      <description>&lt;p&gt;I'm new to react and I am trying to hit an API using &lt;code&gt;fetch&lt;/code&gt; and then &lt;code&gt;setState&lt;/code&gt; to a state variable but it is throwing the error as&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Unhandled Rejection (TypeError): Object(...) is not a function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/frosty-breeze-ori5f?file=/src/App.js"&gt;CodeSandboxLink&lt;/a&gt;&lt;br&gt;
Below is the code&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import { useState, useEffect, setState } from "react";
import "./styles.css";

export default function App() {
  const [person, setPerson] = useState([]);
  fetch("https://jsonplaceholder.typicode.com/users")
    .then((response) =&amp;gt; {
      return response.json();
    })
    .then((data) =&amp;gt; {
      setState(data);
    });
  console.log("dasdasd", person);
  return &amp;lt;div className="App"&amp;gt;{JSON.stringify(person)}&amp;lt;/div&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Please suggest where I am doing wrong.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Reactjs fetch API request getting blocked by CORS policy</title>
      <dc:creator>Sai Avinash Duddupudi</dc:creator>
      <pubDate>Sun, 20 Dec 2020 14:35:07 +0000</pubDate>
      <link>https://dev.to/saiavinashiitr/reactjs-fetch-api-request-getting-blocked-by-cors-policy-10d4</link>
      <guid>https://dev.to/saiavinashiitr/reactjs-fetch-api-request-getting-blocked-by-cors-policy-10d4</guid>
      <description>&lt;p&gt;I am able to hit an sample endpoint via &lt;code&gt;fetch&lt;/code&gt; and display the data in the UI. But for some endpoints, the request is &lt;code&gt;getting blocked by CORS policy&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I also tried to add &lt;code&gt;"proxy" : "endpoint_link"&lt;/code&gt; in &lt;code&gt;package.json&lt;/code&gt; and also tried to add &lt;code&gt;allow Access Origin in the headers section&lt;/code&gt; but the issue still persists&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/tender-butterfly-js7if?file=/src/App.js"&gt;Here is the code which is working fine&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the console log I am getting&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Access to fetch at 'http://localhost:8000/header' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Please suggest how to overcome this during development as I have tried all possible ways.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
