Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

download json file react


  const exportData = () => {
    const jsonString = `data:text/json;chatset=utf-8,${encodeURIComponent(
      JSON.stringify(data)
    )}`;
    const link = document.createElement("a");
    link.href = jsonString;
    link.download = "data.json";

    link.click();
  };

  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
      <button type="button" onClick={exportData}>
        Export Data
      </button>
    </div>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js math.trunc 
Javascript :: index.js:3 Uncaught ReferenceError: $ is not defined at index.js:3 
Javascript :: javascript break foreach 
Javascript :: js print array without comma 
Javascript :: javascript check if element is visible on screen 
Javascript :: mongodb $in regex 
Javascript :: past value from parent in reactjs 
Javascript :: detect if two line segments intersect each other javascript 
Javascript :: how to make form in javascript 
Javascript :: get client id socket io 
Javascript :: how to cache data in javascript 
Javascript :: javascript two digits number 
Javascript :: How to access return value of promise 
Javascript :: Material-ui add alert icon 
Javascript :: javascript falsy 
Javascript :: react text input onchange 
Javascript :: js how to reverse a string 
Javascript :: javascript queryselector child element 
Javascript :: json data sample 
Javascript :: get first word in javascript 
Javascript :: jquery on wheel event 
Javascript :: react js loop through array of objects 
Javascript :: get last word in string js 
Javascript :: js replace multiple 
Javascript :: how to prevent event capturing in javascript 
Javascript :: jquery dropdown select 
Javascript :: json update pytohn 
Javascript :: javascript copy to clipboard 
Javascript :: javascript largest number in array 
Javascript :: ifsc code validation regex 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =