'Filtering data from API in React

I'd like to be able to filter the results from my API. The data is from a SSMS database that the API sends to react through the controller URL. I would like to be able to filter the results to show information pertinent to only one session for example instead of iterating through.

import React, { Component } from 'react';
import { variables } from '../../Components/Variables';

export class AddWorkout extends Component {

    constructor(props){
        super(props);

        this.state={
        sessions:[]
        };
    }

    refreshList() {
        fetch(variables.API_URL+'sessions')
        .then(response=>response.json())
        .then(data=>{
        this.setState({sessions:data});
        });
    }

    componentDidMount() {
        this.refreshList();
    }
    render() {

    const {
        sessions
    }=this.state;

    const current = new Date();
    const dates = `${current.getMonth()+1}/${current.getDate()}/${current.getFullYear()}`;

      return (

        <div id="main-screen" className="main-screen">
            <table className='table table-striped table-bordered'>
                <thead>
                    <tr>
                        <th>Session</th>
                        <th>Date</th>
                        <th>Time</th>
                        <th>Today's Date</th>
                    </tr>
                </thead>
                <tbody>
                    {sessions.map(sessions=>
                        <tr key={sessions.session}>
                            <td>{sessions.session}</td>
                            <td>{sessions.session_date}</td>
                            <td>{sessions.session_time}</td>
                            <td>{dates}</td>
                        </tr>
                    )}
                </tbody>
            </table>



        </div>
      )
   }
}

export default AddWorkout;

Variables Component:

export const variables={
    API_URL: "https://localhost:XXXXX/api/",
}

In the end I would like to only display the sessions from the current date on the screen for example. Thanks for any help!



Solution 1:[1]

It would be appear to be the case that if successfully decrypted (i.e if 'cryptocode is amazing' was the correct password), then message (the content of key once decrypted) contains the time of expiration in float format. Hence, the line you're asking about converts it into float and compares it with the current time to check if it had already expired. (If the current time > expiration time, then the expiration time is in the past: the key had, indeed, already expired.)

In other words: there's an implicit assumption here that the key given to the user was the expiration time, encrypted.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1