{"id":1244,"date":"2023-12-05T14:16:13","date_gmt":"2023-12-05T06:16:13","guid":{"rendered":"https:\/\/www.tonghin.com.my\/blog\/?p=1244"},"modified":"2023-12-05T14:16:14","modified_gmt":"2023-12-05T06:16:14","slug":"implementation-of-api","status":"publish","type":"post","link":"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/","title":{"rendered":"Implementation of API"},"content":{"rendered":"\n<p>Last week, I finished integrating the API into the React website. This API will establish a data link between the database and the system. At first, I didn&#8217;t realize the APIprovided by my colleagues had many methods such as getByIdAsync, getListAsync, updateAsync, deleteAsync, and createAsync. In my development, I only used getListAsync for displaying purposes. I did not concentrate on using the API to create, update, and delete entities. However, the getListAsync method will not return information about a specific customer. I need to use getByIdAsync to view all of the data for a single customer. For example, the addresses types were missing from getAsync but were present in getByIdAsync. Thus, I need to use all the methods for the customer page.<\/p>\n\n\n\n<p>When the system was first being developed, I struggled with the create new customer and modify an existing customer. It&#8217;s because they&#8217;ll be using the same module to display the data. I used to just pass the length of the array as the ID of a new customer, but I changed my mind. When setting the value, I will now pass the ID as undefined to the module and\/or method. Because the react hook form requires the use of setValue when passing data to the module, I used the &#8220;||&#8221; to determine the data&#8217;s existence. When getByIdAsync returns an undefined Id, I setValue to null and convert this file into a create customer form.<br><br>Aside from that, the provided API lacks of customer types yet includes the address name and address remark. Following Mr. Peter&#8217;s clarification, I should revise the customer page prototype to include the address name and address remark instead. Fortunately, these minor changes are straightforward; I only need to add two new text boxes to the address column. Furthermore, I successfully\u00a0\u00a0eliminate the\u00a0duplicate code. The code was now shorter, and fewer files were required for each page.<\/p>\n\n\n\n<p>By the end of the week, I couldn&#8217;t connect to the API&#8217;s POST function. I informed Mr. Peter and will resolve the issue within the next week. I believe that the customer page will be completed within the next week, at which point I will embark on the journey of creating the main page. I only have one month to finish the main pages, and I&#8217;m hoping to finish them before the internship ends.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week, I finished integrating the API into the React website. This API will establish a data link between the database and the system. At first, I didn&#8217;t realize the APIprovided by my colleagues had many methods such as getByIdAsync, getListAsync, updateAsync, deleteAsync, and createAsync. In my development, I only used getListAsync for displaying purposes. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Implementation of API&#8221;<\/span><\/a><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Implementation of API | Tong Hin&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Implementation of API | Tong Hin&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"Last week, I finished integrating the API into the React website. This API will establish a data link between the database and the system. At first, I didn&#8217;t realize the APIprovided by my colleagues had many methods such as getByIdAsync, getListAsync, updateAsync, deleteAsync, and createAsync. In my development, I only used getListAsync for displaying purposes. &hellip; Continue reading &quot;Implementation of API&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/\" \/>\n<meta property=\"og:site_name\" content=\"Tong Hin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-12-05T06:16:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-05T06:16:14+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\",\"name\":\"TONG HIN MACHINERY\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"sameAs\":[\"https:\/\/www.youtube.com\/channel\/UC60EoxJMNbu8mV0LuEGfrBg\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/wp-content\/uploads\/2020\/10\/web_logo_180_180.jpg\",\"width\":180,\"height\":180,\"caption\":\"TONG HIN MACHINERY\"},\"image\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Tong Hin&#039;s Blog\",\"description\":\"Sharing About Technology\",\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tonghin.com.my\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/#webpage\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/\",\"name\":\"Implementation of API | Tong Hin&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\"},\"datePublished\":\"2023-12-05T06:16:13+00:00\",\"dateModified\":\"2023-12-05T06:16:14+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/\",\"name\":\"Implementation of API\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/f7817effc288d9b460c236e6f8a80e05\"},\"headline\":\"Implementation of API\",\"datePublished\":\"2023-12-05T06:16:13+00:00\",\"dateModified\":\"2023-12-05T06:16:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"articleSection\":\"Experiential\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2023\/12\/05\/implementation-of-api\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/f7817effc288d9b460c236e6f8a80e05\",\"name\":\"Chia Soon Tock\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fc0129e896a1c25c18e5c5fabe0016f9?s=96&d=mm&r=g\",\"caption\":\"Chia Soon Tock\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1244"}],"collection":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/comments?post=1244"}],"version-history":[{"count":2,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1244\/revisions"}],"predecessor-version":[{"id":1258,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/1244\/revisions\/1258"}],"wp:attachment":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/media?parent=1244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/categories?post=1244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/tags?post=1244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}