バックエンドはハル先生の<a href="https://youtu.be/pPvPX8kXh7w" _blank=true>動画</a> を参考にして、フロントサイドはハル先生のサブスク有料会員の動画を参考にしてwebアプリを作っています。なんとかuser_createで仮登録機能は実装できたのですが、activationで本登録をする為の方法が全く思い浮かびません、そして色々調べてみたのですが3日ほど答えを見つけられずにいます。もし、activationによる本登録がpostmanを使わずにnext.jsとDjangoなどで可能でしたらやり方を教えていただきたいです。
Djoserのactivationを使っての本登録のやり方が全くわからない。
バックエンドはハル先生の<a href="https://youtu.be/pPvPX8kXh7w" _blank=true>この動画</a>とほとんど同じです。
<p>Reactサイド</p>export default async(req, res) => { if(req.method === 'POST'){ const { name, email, password, re_password } = req.body const body=JSON.stringify({ name, email, password, re_password, }) try{ const apiRes = await fetch(`${process.env.NEXT_PUBLIC_API_URL}api/auth/users/`,{ method: 'POST', headers: { 'Content-Type': 'application/json', }, body: body, }) const data = await apiRes.json() if (apiRes.status === 201){ return res.status(200).json({ success: 'Account registration is successed!', }) }else{ return res.status(apiRes.status).json({ error: 'We failed to register your account', }) } }catch(err){ return res.status(500).json({ error: 'We failed to register your account', }) } }else{ res.setHeader('Allow', ['POST']) return res.status(405).json({ error: `Method ${req.method} not allowded.` }) } }
export default async(req, res) => { if(req.method === 'POST'){ const { name, email, password, re_password } = req.body const body=JSON.stringify({ name, email, password, re_password, }) try{ const apiRes = await fetch(`${process.env.NEXT_PUBLIC_API_URL}api/auth/users/`,{ method: 'POST', headers: { 'Content-Type': 'application/json', }, body: body, }) const data = await apiRes.json() if (apiRes.status === 201){ return res.status(200).json({ success: 'Account registration is successed!', }) }else{ return res.status(apiRes.status).json({ error: 'We failed to register your account', }) } }catch(err){ return res.status(500).json({ error: 'We failed to register your account', }) } }else{ res.setHeader('Allow', ['POST']) return res.status(405).json({ error: `Method ${req.method} not allowded.` }) } }
Googleで日本語と英語で調べまくる。 Chat GPTに聞いてみる。
いつもお世話になっております。