<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why is my Rest API call not working properly? in cybersource APIs</title>
    <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Why-is-my-Rest-API-call-not-working-properly/m-p/84701#M529</link>
    <description>&lt;P&gt;Hey&lt;A title="," href="https://pintdow.com/how-to-stop-emails-from-pinterest/" target="_blank" rel="noopener"&gt;,&lt;/A&gt;&lt;/P&gt;&lt;P&gt;API failures happen for multiple reasons, but most of them can be boiled down to these three culprits:&amp;nbsp;Software changes happening too quickly.&amp;nbsp;Breakdowns in communication among teams.&amp;nbsp;Bad data that is incompatible with your API.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Oct 2022 11:36:14 GMT</pubDate>
    <dc:creator>joseemily</dc:creator>
    <dc:date>2022-10-28T11:36:14Z</dc:date>
    <item>
      <title>Why is my Rest API call not working properly?</title>
      <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Why-is-my-Rest-API-call-not-working-properly/m-p/82500#M82</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'm making a Pokedex site just for practice and to learn how to properly use API Rest, but I've been having some issues, when you first enter the site the API is called twice for no reason, and when you press the next or previous button you have to press it twice in order to load the prev/next pokemon. I don't understand why it's giving that error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Here is the code were I called the API:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    &lt;SPAN class=""&gt;export&lt;/SPAN&gt; &lt;SPAN class=""&gt;const&lt;/SPAN&gt; &lt;SPAN class=""&gt;CardList&lt;/SPAN&gt; = () =&amp;gt;{
    &lt;SPAN class=""&gt;const&lt;/SPAN&gt; [ pokeInfo, setPokemonInfo ] = &lt;SPAN class=""&gt;useState&lt;/SPAN&gt;([]);
    &lt;SPAN class=""&gt;const&lt;/SPAN&gt; [ loading, setLoading ] = &lt;SPAN class=""&gt;useState&lt;/SPAN&gt;();
    &lt;SPAN class=""&gt;const&lt;/SPAN&gt; [ url, setUrl ] = &lt;SPAN class=""&gt;useState&lt;/SPAN&gt;(&lt;SPAN class=""&gt;'https://pokeapi.co/api/v2/pokemon'&lt;/SPAN&gt;);
    &lt;SPAN class=""&gt;const&lt;/SPAN&gt; [ nextUrl, setNextUrl ] = &lt;SPAN class=""&gt;useState&lt;/SPAN&gt;();
    &lt;SPAN class=""&gt;const&lt;/SPAN&gt; [ prevUrl, setPrevtUrl ] = &lt;SPAN class=""&gt;useState&lt;/SPAN&gt;();
    &lt;SPAN class=""&gt;const&lt;/SPAN&gt; [ pokedex, setPokedex ] = &lt;SPAN class=""&gt;useState&lt;/SPAN&gt;();
    &lt;SPAN class=""&gt;//console.log(pokedex)&lt;/SPAN&gt;

    &lt;SPAN class=""&gt;const&lt;/SPAN&gt; &lt;SPAN class=""&gt;FetchData&lt;/SPAN&gt; = &lt;SPAN class=""&gt;async&lt;/SPAN&gt; () =&amp;gt; {
      &lt;SPAN class=""&gt;//res short for response&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;setLoading&lt;/SPAN&gt;(&lt;SPAN class=""&gt;true&lt;/SPAN&gt;);
      &lt;SPAN class=""&gt;const&lt;/SPAN&gt; res = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; axios.&lt;SPAN class=""&gt;get&lt;/SPAN&gt;(url);
      &lt;SPAN class=""&gt;setNextUrl&lt;/SPAN&gt;(res.&lt;SPAN class=""&gt;data&lt;/SPAN&gt;.&lt;SPAN class=""&gt;next&lt;/SPAN&gt;);
      &lt;SPAN class=""&gt;setPrevtUrl&lt;/SPAN&gt;(res.&lt;SPAN class=""&gt;data&lt;/SPAN&gt;.&lt;SPAN class=""&gt;previous&lt;/SPAN&gt;);
      &lt;SPAN class=""&gt;GetData&lt;/SPAN&gt;(res.&lt;SPAN class=""&gt;data&lt;/SPAN&gt;.&lt;SPAN class=""&gt;results&lt;/SPAN&gt;);
      &lt;SPAN class=""&gt;setLoading&lt;/SPAN&gt;(&lt;SPAN class=""&gt;false&lt;/SPAN&gt;);
    }

    &lt;SPAN class=""&gt;const&lt;/SPAN&gt; &lt;SPAN class=""&gt;GetData&lt;/SPAN&gt; = &lt;SPAN class=""&gt;async&lt;/SPAN&gt;(res) =&amp;gt;{
      res.&lt;SPAN class=""&gt;map&lt;/SPAN&gt; ( &lt;SPAN class=""&gt;async&lt;/SPAN&gt;(item) =&amp;gt;{
        &lt;SPAN class=""&gt;const&lt;/SPAN&gt; result = &lt;SPAN class=""&gt;await&lt;/SPAN&gt; axios.&lt;SPAN class=""&gt;get&lt;/SPAN&gt;(item.&lt;SPAN class=""&gt;url&lt;/SPAN&gt;)
        &lt;SPAN class=""&gt;//console.log(item.name);&lt;/SPAN&gt;

        &lt;SPAN class=""&gt;setPokemonInfo&lt;/SPAN&gt;(&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;state&lt;/SPAN&gt; =&amp;gt;&lt;/SPAN&gt;{
            state = [...state, result.&lt;SPAN class=""&gt;data&lt;/SPAN&gt;]
            state.&lt;SPAN class=""&gt;sort&lt;/SPAN&gt;(&lt;SPAN class=""&gt;(&lt;SPAN class=""&gt; a, b &lt;/SPAN&gt;) =&amp;gt;&lt;/SPAN&gt; a.&lt;SPAN class=""&gt;id&lt;/SPAN&gt; &amp;gt; b.&lt;SPAN class=""&gt;id&lt;/SPAN&gt; ? &lt;SPAN class=""&gt;1&lt;/SPAN&gt; : -&lt;SPAN class=""&gt;1&lt;/SPAN&gt;)
            &lt;SPAN class=""&gt;return&lt;/SPAN&gt; state;
        })
      })
    }

    &lt;SPAN class=""&gt;useEffect&lt;/SPAN&gt;(&lt;SPAN class=""&gt;() =&amp;gt;&lt;/SPAN&gt; {
      &lt;SPAN class=""&gt;FetchData&lt;/SPAN&gt;();
    }, []);

  &lt;SPAN class=""&gt;return&lt;/SPAN&gt;(
    &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;lt;&lt;SPAN class=""&gt;div&lt;/SPAN&gt; &lt;SPAN class=""&gt;className&lt;/SPAN&gt;=&lt;SPAN class=""&gt;""&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;&amp;lt;&lt;SPAN class=""&gt;MoreInfo&lt;/SPAN&gt; &lt;SPAN class=""&gt;data&lt;/SPAN&gt;=&lt;SPAN class=""&gt;{pokedex}/&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;

      &lt;SPAN class=""&gt;&amp;lt;&lt;SPAN class=""&gt;div&lt;/SPAN&gt; &lt;SPAN class=""&gt;className&lt;/SPAN&gt;=&lt;SPAN class=""&gt;"cardList flexbox"&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN class=""&gt;&amp;lt;&lt;SPAN class=""&gt;Card&lt;/SPAN&gt; &lt;SPAN class=""&gt;pokemon&lt;/SPAN&gt;=&lt;SPAN class=""&gt;{pokeInfo}&lt;/SPAN&gt; &lt;SPAN class=""&gt;loading&lt;/SPAN&gt;=&lt;SPAN class=""&gt;{loading}&lt;/SPAN&gt; &lt;SPAN class=""&gt;infoPokemon&lt;/SPAN&gt;=&lt;SPAN class=""&gt;{item&lt;/SPAN&gt;=&amp;gt;&lt;/SPAN&gt;setPokedex(item)}/&amp;gt;
      &lt;SPAN class=""&gt;&amp;lt;/&lt;SPAN class=""&gt;div&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;&amp;lt;&lt;SPAN class=""&gt;div&lt;/SPAN&gt; &lt;SPAN class=""&gt;className&lt;/SPAN&gt;=&lt;SPAN class=""&gt;"btnContainer center"&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;
            &lt;SPAN class=""&gt;&amp;lt;&lt;SPAN class=""&gt;button&lt;/SPAN&gt; &lt;SPAN class=""&gt;className&lt;/SPAN&gt;=&lt;SPAN class=""&gt;"btn"&lt;/SPAN&gt; &lt;SPAN class=""&gt;onClick&lt;/SPAN&gt;=&lt;SPAN class=""&gt;{()&lt;/SPAN&gt; =&amp;gt;&lt;/SPAN&gt;{
                setLoading(true)
                setPokemonInfo([])
                setUrl(prevUrl)
                FetchData()
                setLoading(false);
          }}&amp;gt;

              Previous
          &lt;SPAN class=""&gt;&amp;lt;/&lt;SPAN class=""&gt;button&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;
          
          &lt;SPAN class=""&gt;&amp;lt;&lt;SPAN class=""&gt;button&lt;/SPAN&gt; &lt;SPAN class=""&gt;className&lt;/SPAN&gt;=&lt;SPAN class=""&gt;"btn"&lt;/SPAN&gt;  &lt;SPAN class=""&gt;onClick&lt;/SPAN&gt;=&lt;SPAN class=""&gt;{()&lt;/SPAN&gt; =&amp;gt;&lt;/SPAN&gt;{
                setLoading(true)
                setPokemonInfo([])
                setUrl(nextUrl)
                FetchData()
                setLoading(false);
            }}&amp;gt;

                Next
          &lt;SPAN class=""&gt;&amp;lt;/&lt;SPAN class=""&gt;button&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;

      &lt;SPAN class=""&gt;&amp;lt;/&lt;SPAN class=""&gt;div&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;&amp;lt;/&lt;SPAN class=""&gt;div&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
  );
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 05:18:40 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/cybersource-APIs/Why-is-my-Rest-API-call-not-working-properly/m-p/82500#M82</guid>
      <dc:creator>StanGilbertland</dc:creator>
      <dc:date>2022-05-06T05:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my Rest API call not working properly?</title>
      <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Why-is-my-Rest-API-call-not-working-properly/m-p/82850#M136</link>
      <description>&lt;P&gt;The component is being forced to unmount and remount on its initial render. This could be something like a "key" change happening higher up the tree. you need to go up each level with this useEffect until it renders only once. then you should be able to find the cause or the remount.&lt;/P&gt;&lt;H2&gt;React.Strict mode is on&lt;/H2&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;StrictMode renders components twice (on dev but not production) in order to detect any problems with your code and warn you about them (which&amp;nbsp;omegle.club can be quite&amp;nbsp;omegle.ws useful).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 24 May 2022 12:19:06 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/cybersource-APIs/Why-is-my-Rest-API-call-not-working-properly/m-p/82850#M136</guid>
      <dc:creator>StanGilbertland</dc:creator>
      <dc:date>2022-05-24T12:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my Rest API call not working properly?</title>
      <link>https://community.developer.cybersource.com/t5/cybersource-APIs/Why-is-my-Rest-API-call-not-working-properly/m-p/84701#M529</link>
      <description>&lt;P&gt;Hey&lt;A title="," href="https://pintdow.com/how-to-stop-emails-from-pinterest/" target="_blank" rel="noopener"&gt;,&lt;/A&gt;&lt;/P&gt;&lt;P&gt;API failures happen for multiple reasons, but most of them can be boiled down to these three culprits:&amp;nbsp;Software changes happening too quickly.&amp;nbsp;Breakdowns in communication among teams.&amp;nbsp;Bad data that is incompatible with your API.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2022 11:36:14 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/cybersource-APIs/Why-is-my-Rest-API-call-not-working-properly/m-p/84701#M529</guid>
      <dc:creator>joseemily</dc:creator>
      <dc:date>2022-10-28T11:36:14Z</dc:date>
    </item>
  </channel>
</rss>

