text: (window["webpackJsonpnews-app"]=window["webpackJsonpnews-app"]||[]).push([[0],{109:function(e,t,r){"use strict";r.r(t);var n=r(0),a=r.n(n),c=r(20),o=r.n(c),s=(r(73),r(24)),i=r.n(s),l=r(61),u=r(38),p=r(63),m=function(){var e=Object(u.a)(i.a.mark((function e(t){var r,n;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("https://api.nytimes.com/svc/search/v2/articlesearch.json?q=".concat(t,"&api-key=").concat("5OaCqqTaMdzP7bShUAUBw60D9hf6v5ig"));case 2:return r=e.sent,e.next=5,r.json();case 5:return n=e.sent,e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),f=r(125),h=r(128),d=r(130),g=r(113),y=r(129);function b(e){var t=e.article;return a.a.createElement(f.a,{item:!0,xs:12,sm:12,md:12},a.a.createElement(h.a,{className:"card"},a.a.createElement(y.a,{href:t.web_url},a.a.createElement(d.a,null,a.a.createElement(g.a,{gutterBottom:!0,variant:"h5",component:"h2"},t.headline.main),a.a.createElement(g.a,null,t.abstract)))))}var E=function(e){return a.a.createElement(f.a,{container:!0,spacing:4},e.articles.map((function(e,t){return a.a.createElement(b,{article:e,key:e.title+t})})))},w=r(62),v=r.n(w),O=r(131);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(r,!0).forEach((function(t){Object(l.a)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(r).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var P=function(){var e=Object(n.useState)({articles:[],searchTopic:"",totalResults:"",loading:!1,apiError:""}),t=Object(p.a)(e,2),r=t[0],c=t[1],o=function(){var e=Object(u.a)(i.a.mark((function e(t){var n;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,c(x({},r,{loading:!0})),e.next=4,m(t);case 4:n=e.sent,console.log(n),c(x({},r,{articles:n.response.docs,searchTopic:t,totalResults:10})),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),r.apiError="Could not find any articles";case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t){return e.apply(this,arguments)}}();return a.a.createElement(O.a,{className:"cardGrid",maxWidth:"md"},a.a.createElement("h1",{style:{textAlign:"center"}},"News Search"),a.a.createElement(v.a,{onChange:function(e){r.searchTopic=e},onRequestSearch:function(){o(r.searchTopic),c(x({},r,{loading:!1}))}}),a.a.createElement("p",{style:{textAlign:"center"}},"Powered by ",a.a.createElement("a",{href:"https://nytimes.com/"},"NY Times")),r.loading&&a.a.createElement("p",{style:{textAlign:"center"}},"Searching for articles..."),r.articles.length>0&&a.a.createElement("h4",{style:{textAlign:"center",margin:20}},"Found ",r.totalResults,' articles for "',r.searchTopic,'"'),r.articles.length>0&&a.a.createElement(E,{articles:r.articles}),0===r.articles.length&&a.a.createElement("p",null,"Could not fetch any articles. Please try again."))};r(105);o.a.render(a.a.createElement(P,null),document.getElementById("root"))},68:function(e,t,r){e.exports=r(109)},73:function(e,t,r){}},[[68,1,2]]]);
  //# sourceMappingURL=main.dc1c6452.chunk.js.map