Forum

Db8 using enact

can anyone give a little insight with how to implement the queries in db8 using the webos library in enact a small spinet of code will be helpful.

Hi Zubbin,
You can refer below code for enact library to make LS2 request

import {Panel, Header} from '@enact/sandstone/Panels';
import LS2Request from '@enact/webos/LS2Request';
import React from 'react';
class LunaExample extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            loading:true,
            data:""
        }
    }
    componentDidMount = () => {
        new LS2Request().send(
			{
				service: 'luna://com.webos.service.systemservice/clock',
				method: 'getTime',
				parameters: {},
				onSuccess: (data) =>{
					console.log("data",data)
                    this.setState({
                        data:"Success"
                    })
                },
                onFailure: (error) =>{
                    this.setState({
                        data:"Failed"
                    })
                },
                onComplete: () =>{
                    this.setState({
                        loading:false
                    })
                    console.log("On Complete service request")
                }
			}
		);
    }
    render = () => {
        const loading = this.state.loading ? "Loading..." : this.state.data
        return(
            <div>
               <Header>{loading}</Header> 
            </div>
        )
    }
}



export default LunaExample;

You can check with DB8 team to understand the DB8 functionality and API information
Thanks,