Skip to content

Commit a9ed8db

Browse files
committed
feat: add with-node.js example
1 parent 4169682 commit a9ed8db

File tree

5 files changed

+195
-1
lines changed

5 files changed

+195
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const { submit } = useWeb3forms<FormData>({
103103

104104
> Make sure you provide a json with atleast one key-value pair to `submit`
105105
106-
For other examples please look into the examples directory. If you cannot find your favourite library, just open a issue or just make a tiny contribution 😉
106+
For other examples please look into the [examples](https://github.com/Lalit2005/use-web3forms/tree/master/examples/) directory. If you cannot find your favourite library/framework, just open a issue or just make a tiny contribution 😉
107107

108108
---
109109
## FAQ ❓

examples/with-node.js/.gitignore

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Microbundle cache
58+
.rpt2_cache/
59+
.rts2_cache_cjs/
60+
.rts2_cache_es/
61+
.rts2_cache_umd/
62+
63+
# Optional REPL history
64+
.node_repl_history
65+
66+
# Output of 'npm pack'
67+
*.tgz
68+
69+
# Yarn Integrity file
70+
.yarn-integrity
71+
72+
# dotenv environment variables file
73+
.env
74+
.env.test
75+
.env.production
76+
77+
# parcel-bundler cache (https://parceljs.org/)
78+
.cache
79+
.parcel-cache
80+
81+
# Next.js build output
82+
.next
83+
out
84+
85+
# Nuxt.js build / generate output
86+
.nuxt
87+
dist
88+
89+
# Gatsby files
90+
.cache/
91+
# Comment in the public line in if your project uses Gatsby and not Next.js
92+
# https://nextjs.org/blog/next-9-1#public-directory-support
93+
# public
94+
95+
# vuepress build output
96+
.vuepress/dist
97+
98+
# Serverless directories
99+
.serverless/
100+
101+
# FuseBox cache
102+
.fusebox/
103+
104+
# DynamoDB Local files
105+
.dynamodb/
106+
107+
# TernJS port file
108+
.tern-port
109+
110+
# Stores VSCode versions used for testing VSCode extensions
111+
.vscode-test
112+
113+
# yarn v2
114+
.yarn/cache
115+
.yarn/unplugged
116+
.yarn/build-state.yml
117+
.yarn/install-state.gz
118+
.pnp.*

examples/with-node.js/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const useWeb3forms = require('use-web3forms');
2+
3+
// import isomorphic-unfetch so that a fetch polyfill is added to the global scope
4+
require('isomorphic-unfetch');
5+
6+
const { submit } = useWeb3forms({
7+
apikey: 'YOUR_ACCESS_KEY_HERE',
8+
onError: (msg, err) => {
9+
console.log(msg, '\n', err);
10+
},
11+
onSuccess: (msg, data) => {
12+
console.log(msg, '\n', data);
13+
},
14+
});
15+
16+
submit({
17+
name: 'John Doe',
18+
email: 'john@doe.com',
19+
message: 'Hello, World!',
20+
});

examples/with-node.js/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "with-node.js",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"dependencies": {
7+
"isomorphic-unfetch": "^3.1.0",
8+
"use-web3forms": "^1.2.0"
9+
}
10+
}

examples/with-node.js/yarn.lock

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
isomorphic-unfetch@^3.1.0:
6+
version "3.1.0"
7+
resolved "https://registry.yarnpkg.com/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz#87341d5f4f7b63843d468438128cb087b7c3e98f"
8+
integrity sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==
9+
dependencies:
10+
node-fetch "^2.6.1"
11+
unfetch "^4.2.0"
12+
13+
node-fetch@^2.6.1:
14+
version "2.6.5"
15+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.5.tgz#42735537d7f080a7e5f78b6c549b7146be1742fd"
16+
integrity sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==
17+
dependencies:
18+
whatwg-url "^5.0.0"
19+
20+
tr46@~0.0.3:
21+
version "0.0.3"
22+
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
23+
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=
24+
25+
unfetch@^4.2.0:
26+
version "4.2.0"
27+
resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.2.0.tgz#7e21b0ef7d363d8d9af0fb929a5555f6ef97a3be"
28+
integrity sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==
29+
30+
use-web3forms@^1.2.0:
31+
version "1.2.0"
32+
resolved "https://registry.yarnpkg.com/use-web3forms/-/use-web3forms-1.2.0.tgz#ce9743cd2330eb7eac15702b91c48dc54414a889"
33+
integrity sha512-kAzKUvhNaQ/N+A51NU1/uqTjQR1w5zqnknVNGb0ftXUsGOXgrG27nlQCKjG4vcO/Qtul9IB8mBiDG6NRVXZ9rA==
34+
35+
webidl-conversions@^3.0.0:
36+
version "3.0.1"
37+
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
38+
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=
39+
40+
whatwg-url@^5.0.0:
41+
version "5.0.0"
42+
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
43+
integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0=
44+
dependencies:
45+
tr46 "~0.0.3"
46+
webidl-conversions "^3.0.0"

0 commit comments

Comments
 (0)