Home  >  Q&A  >  body text

API returns empty payload on live server but not on localhost

This is the response I got using the localhost API

This is the response I get using the staging API deployed on the renderer

This is how I call the API

const [data, setData] = useState([]);

useEffect(() => {
    const getSandboxKey = async () => {
    
        const config = {
          headers: {
            Authorization: `Bearer ${token}`,
          },
        };
    
        const response = await axios.get(
          `API_URL/api/v1/organization/get-sandbox-keys`,
          config
        );
    
        setData(response.data.payload[0]);
      };

         getSandboxKey();
       }, []);

return (
<div>{data.secretKey}</div>
<div>{data.publicKey}</div>
<div>{data.mode}</div>
)

I'm trying to get some data from the payload. It works perfectly on localhost

P粉618358260P粉618358260181 days ago340

reply all(1)I'll reply

  • P粉935883292

    P粉9358832922024-04-03 10:00:51

    At first glance, I would check if tokens are the issue here. Some questions you might consider:

    • How to save the token?
    • Can the same token be used for localhost and staging? Or should they be different?
    • Did you refresh the (possibly cached) token before testing the staging?

    reply
    0
  • Cancelreply