
SuperAgent Has a Free API — Here's How to Use This Flexible HTTP Client
SuperAgent is a progressive HTTP client for Node.js and browsers. Its chainable API makes building complex requests intuitive and readable. Installation npm install superagent Basic Requests import request from " superagent " ; // GET with query parameters const { body } = await request . get ( " https://api.github.com/search/repositories " ) . query ({ q : " web scraping " , sort : " stars " , per_page : 5 }) . set ( " User-Agent " , " superagent-example " ); body . items . forEach ( repo => console . log ( ` ${ repo . full_name } : ${ repo . stargazers_count } stars` )); POST and PUT // POST JSON const response = await request . post ( " https://httpbin.org/post " ) . send ({ name : " SuperAgent " , type : " http-client " }) . set ( " Content-Type " , " application/json " ); console . log ( response . body . json ); // PUT with auth await request . put ( " https://api.example.com/users/1 " ) . auth ( " username " , " password " ) . send ({ name : " Updated Name " }); File Upload cons
Continue reading on Dev.to Webdev
Opens in a new tab

