'getting error during the pass value to the database react shopify app

I'm learning to create Shopify custom app using PHP+Laravel/React js, i have created one form that has some fields, and that fields data I'm stored to the database but when I send data it gives the error.

in this when I have passed the axios.post('/wp_share_cart', data) that is not working, I don't know why it.

enter image description here

Component file code : WhatsappSharecart.jsx

import {gql, useQuery} from '@apollo/client';
import {Banner, AppProvider} from '@shopify/polaris';
import React from 'react';
import {Component} from 'react';
import ReactDOM from 'react-dom';
import {Loading} from '@shopify/app-bridge-react';
import app from "/css/app.css";
import { useReducer, useState } from 'react';
import axios from 'axios';
import { useNavigate } from 'react-router-dom'
import {Provider, useAppBridge, TitleBar} from '@shopify/app-bridge-react';



function WhatsappSharecart() {    
    
    const [wp_enable, setWpEnable] = useState("No");
    const [buttonlabel, setButtonlabel] = useState("Share on WhatsApp");
    const [cartmessage, setCartmessage] = useState("Hey! There Watch My Cart.");
    const [buttonposition, setButtonposition] = useState("Default");
    
    const [bitlyenable, setBitlyenable] = useState("No");
    const [bit_token, setBitToken] = useState("Enter Bitly Access Token");

    const handleChange = (event) => {
       setWpEnable(event.target.value);  
       setButtonposition(event.target.value);

       setBitlyenable(event.target.value); 
    }
      
    /*const handleSubmit = event => {
       event.preventDefault();       
       alert(`Whatsapp Share Cart Enable: ${wp_enable}`)
       alert(`Button Label Is: ${buttonlabel}`)
       alert(`Cart Message on Whatsapp Share Link Is: ${cartmessage}`)
       alert(`Whatsapp Button Position on Cart Page Is: ${buttonposition}`)      
       console.log(buttonlabel);       
    }*/

   const handleSubmit = event =>{
        event.preventDefault();
        
        const data = {
          wp_enable: wp_enable,
          buttonlabel: buttonlabel,
          cartmessage: cartmessage,
          buttonposition: buttonposition,
          bitlyenable: bitlyenable,
          bit_token: bit_token
          
        }
        
        /*fetch( '/api/wp_share_cart', {
            method:'post',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
            },
            body: JSON.stringify()
        })
        .then(response => {
            return response.json();
        })
        .then(data => {
            //update the state of links
        });*/        
        axios.post('/wp_share_cart', data)           
            .then((response) => {
                console.log(response .data)
            }).catch((error) => {
                console.log(error)
            });
    }

    const handleAlternate = event => {
      event.preventDefault(); 
      alert(`Bitly Short URL Enable: ${bitlyenable}`)
      alert(`Bitly Generic Access Token: ${bit_token}`)
    }

    return (
      <div className="wp_share_cart">
        <h1>General Configuration</h1>
        <form onSubmit={handleSubmit}>
          <fieldset>

            <label>
              <p>Whatsapp Share Cart Enable</p>
              <select value={wp_enable} onChange={handleChange}>
              {/*<option value="">--Please choose an option--</option>*/}
                <option value="Yes">Yes</option>
                <option value="No"> No </option>          
              </select>
            </label>

            <label>
              <p>Button Label Text</p>
              <input type="text" 
                     value={buttonlabel}
                     onChange={(e) => setButtonlabel(e.target.value)}
                     name="wp_share_cart_label"/>
            </label>

            <label>
              <p>Cart Message on Whatsapp Share Link</p>          
              <textarea value={cartmessage} onChange={(e) => setCartmessage(e.target.value)} />
            </label>

            <label>
              <p>Whatsapp Button Position on Cart Page</p>
              <select value={buttonposition} onChange={(e) => setButtonposition(e.target.value)}>
                  {/*<option value="">--Please choose an option--</option>*/}
                  <option value="Default">  Dafault   </option>
                  <option value="Left">     Left      </option>
                  <option value="Center">   Center    </option>
                  <option value="Right">    Right     </option>                            
              </select>
            </label>  

          </fieldset> 
          <button type="submit">Save Configuration</button>


          <h1>Enable Bitly Short URL Settings</h1>
           <fieldset>

            <label>
              <p>Bitly Short URL Enable</p>
              <select value={bitlyenable} onChange={handleChange}>
              {/*<option value="">--Please choose an option--</option>*/}
                <option value="Yes">Yes</option>
                <option value="No"> No </option>          
              </select>
            </label>

            <label>
              <p>Bitly Generic Access Token</p>          
              <textarea value={bit_token} onChange={(e) => setToken(e.target.value)} />
            </label>

          </fieldset> 
          <button type="submit" onClick={handleAlternate}> Save Configuration</button>

        </form>
      </div>
    )
}
export default WhatsappSharecart;

Controller File : InsertwpdataController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class InsertwpdataController extends Controller
{   
    public function index()
    {
        return view('products');
    }

    public function wp_share_cart(Request $request)
    {
        //dd('test132');
        
        $wp_enable          = $request->input('wp_enable')
        $buttonlabel        = $request->input('buttonlabel')
        $cartmessage        = $request->input('cartmessage')
        $buttonposition     = $request->input('buttonposition')

        $bitlyenable        = $request->input('bitlyenable')
        $bit_token          = $request->input('bit_token');
    }
}

Router file code: web.php

Route::post('/','InsertwpdataController@wp_share_cart');

Route List

Illuminate\Contracts\Container\BindingResolutionException

  Target class [InsertwpdataController] does not exist.

  at E:\xampp\htdocs\shopifyapps\whatsapp_share_cart\vendor\laravel\framework\src\Illuminate\Container\Container.php:875
    871▕
    872▕         try {
    873▕             $reflector = new ReflectionClass($concrete);
    874▕         } catch (ReflectionException $e) {
  ➜ 875▕             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    876▕         }
    877▕
    878▕         // If the type is not instantiable, the developer is attempting to resolve
    879▕         // an abstract type such as an Interface or Abstract Class and there is

  1   [internal]:0
      Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))

  2   E:\xampp\htdocs\shopifyapps\whatsapp_share_cart\vendor\laravel\framework\src\Illuminate\Container\Container.php:873
      ReflectionException::("Class InsertwpdataController does not exist")

   Whoops\Exception\ErrorException

  Module 'openssl' already loaded

  1   E:\xampp\htdocs\shopifyapps\whatsapp_share_cart\vendor\filp\whoops\src\Whoops\Run.php:486
      Whoops\Run::handleError("Module 'openssl' already loaded", "Unknown")

  2   [internal]:0
      Whoops\Run::handleShutdown()


Solution 1:[1]

You have to remove the dump and die function from your controller (dd('test132');).

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 A.Seddighi