Disallow providing a body with GET or HEAD fetch requests.
✅ This rule is included in the ts logical and logicalStrict presets.
The Fetch API throws a TypeError at runtime when the request method is GET or HEAD and a body is provided.
This rule detects fetch() calls and new Request() calls that provide a body with a GET or HEAD method.
HTTP methods GET and HEAD are intended to retrieve data without sending a request body.
Per the Fetch specification, providing a body with these methods is invalid and will cause the browser or runtime to throw an error.
AEconsB0responAE = awaiB0fet5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D/a1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE, { body1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dda1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">53 }sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0responAE = awaiB0fet5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D/a1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE, { method1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4DG1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE, body1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dda1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">53 }sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0responAE = awaiB0fet5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D/a1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE, { method1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4DHE1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE, body1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dda1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">53 }sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0requeAE <= sp ansty="le--0:#7FDBCA;--1:#096E">72n= sp>AB0Reque5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D/a1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE, { body1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dda1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">53 }sp><);d ivclassNa="meco"><);d>);d>);d>AEconsB0requeAE <= sp ansty="le--0:#7FDBCA;--1:#096E">72n= sp>AB0Reque5<3(sp ansty="le--0:#D9F5DD;--1:#1111">13(sp><1"sp ansty="le--0:#ECC48D;--1:#984E">4D/a1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE, { method1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4DG1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE, body1"sp><: sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Dda1"sp>1<1"sp ansty="le--0:#C792EA;--1:#8844">AE1"sp>< }sp ansty="le--0:#D6DEEB;--1:#403F">53 }sp><);d ivclassNa="meco"><);d>);d>);d> 44AEco61B0resp44AE = aw61B0f31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1/api><111" spans="tyle--0:#D6DEEB;--1:#40">3F111"><53) ;divclass="Name">53)><;di vdivclass="Nameexpressive-">44AEco61B0resp44AE = aw61B0f31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1/api><111" spans="tyle--0:#C792EA;--1:#88">44AE, { meth111">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1<111" spans="tyle--0:#C792EA;--1:#88">44AE, bo111">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1<111" spans="tyle--0:#C792EA;--1:#88">44111">3F<53) ;divclass="Name">< })> })>53)>;di><;di vdivclass="Nameexpressive-">44AEco61B0resp44AE = aw61B0f31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1/api><111" spans="tyle--0:#C792EA;--1:#88">44AE, { meth111">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4111">1<111" spans="tyle--0:#C792EA;--1:#88">44AE, bo111">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1<111" spans="tyle--0:#C792EA;--1:#88">44111">3F<53) ;divclass="Name">< })> })>53)>;di><;di vdivclass="Nameexpressive-">44AEco61B0req44A6E7<2new spans="tyle--0:#C792EA;--1:#88">42new><4AE spans="tyle--0:#82AAFF;--1:#3B">61B0Req4AE >31<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1/api><111" spans="tyle--0:#C792EA;--1:#88">44AE, { meth111">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1<111" spans="tyle--0:#C792EA;--1:#88">44AE, bo111">1<111" spans="tyle--0:#ECC48D;--1:#98">4E4D111">1<111" spans="tyle--0:#C792EA;--1:#88">44111">3F<53) ;divclass="Name">< })> })>53)>;di>
This rule is not configurable.
If your codebase uses a custom fetch wrapper or polyfill that accepts different options, this rule might produce false positives.
You can disable it for files that use such wrappers.