Navigation

    • Register
    • Login
    • Search
    • Recent
    • Users
    • Groups
    1. Home
    2. asaifulas
    A

    asaifulas

    @asaifulas

    0
    Reputation
    2
    Posts
    1
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    asaifulas Follow

    Best posts made by asaifulas

    This user does not have any upvoted posts yet.

    Latest posts made by asaifulas

    RE: React-Laravel-JWT auth

    Tq sir...

    posted in Software Engineering •
    React-Laravel-JWT auth

    Good day Sir @prafful. Im Saiful from MOSTI September Class. I wanna ask a question related to react. Im currently trying to make a web app with react as frontend and laravel as backend. I'm using jwt-auth as 'bridge' and axios in react. Im having trouble to send data and token from react to laravel. Im able to send them separately but not both combine. When I try to send data with token, the data is stored at the config, not at data. Can you guide me the proper way to make a request from react with axios. Thanks in advance.

    JWT library:

    https://laravel-jwt-auth.readthedocs.io/
    

    http axios:

      const http = axios.create({
          baseURL:"http://localhost:8000/api",
          headers:{
              "Content-type":"application/json"
          }
      })
    

    send data with get, and display the response at console:

    const pushData = ()=>{
          http.get('/devices/create', { headers: { Authorization: `Bearer ${token}` }, deviceId:deviceId, deviceName:deviceName, customer:customer }).then((res)=>{
            console.log(res)
            res.status === 200?setIsOpen(false):setFail(true)
          })
        }
    

    DevicesController.php in Laravel just trying to response with the data that being sent:

    public function create()
        {
            return response()->json(['testmasuk' => request(['deviceId', 'deviceName', 'customer'])]);
        }
    

    here is the console output, no data at data->testmasuk, the data are at the config:
    console output.png

    posted in Software Engineering •