-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNwe.js
29 lines (22 loc) · 872 Bytes
/
Nwe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import axios from "axios";
import Post from "../models/post";
import Web3Modal from 'web3modal';
import WalletConnectProvider from "@walletconnect/web3-provider";
import { ethers } from "ethers";
import { contractAddress } from "../constants/Constants";
import { useState, useEffect } from 'react';
export default function getAllposts() {
const [posts, setPosts] = useState();
const abi = ["function writepost(string memory prefName, string memory prefDesc) public"];
useEffect(() => {
get();
}, [])
async function get() {}
async function writepost(name, description) {}
return {posts : posts, writepost : (name, description) => writepost(name, description)};
}
async function get() {
const data = await axios.get('/api/getAllposts');
const result = data.data.map((item) => new Post(item)).reverse();
setPosts(result);
}