Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

axios params onclick function

import axios from "axios";
import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';

export default function App() {
    const [randomQuote, setRandomQuote] = useState('');

    const update = () => {
        axios
            .get(baseURL)
            .then((res) => {
                setRandomQuote(res.data);
            });
    };

    useEffect(update, []);

    if (!randomQuote) return null;


    return (
        <div>
            <QuoteCard
                quote={randomQuote.content}
                author={randomQuote.author}
                handleClick={update}
            />
        </div>
    )
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #axios #params #onclick #function
ADD COMMENT
Topic
Name
4+6 =