API returns empty payload on live server but not on localhost
P粉618358260
P粉618358260 2024-04-02 10:38:21
0
1
435

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粉618358260
P粉618358260

reply all(1)
P粉935883292

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?
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template