{"id":8565,"date":"2022-10-10T21:37:32","date_gmt":"2022-10-10T21:37:32","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8565"},"modified":"2022-10-11T08:26:47","modified_gmt":"2022-10-11T08:26:47","slug":"fetch-no-cors-no-custom-context-type","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/fetch-no-cors-no-custom-context-type\/","title":{"rendered":"fetch, no-cors no custom context type"},"content":{"rendered":"<p><em>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind.<\/em><\/p>\n<p>If you&#8217;re using the Javascript fetch api with <em>mode<\/em> set to &#8216;no-cors&#8217; beware that this limits the set of headers you can use in your request. Specifically if you&#8217;re trying to interact with a server using application\/json, the &#8216;no-cors&#8217; will simply not apply that content-type.<\/p>\n<p><em>See <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Fetch_API\/Using_Fetch\" rel=\"noopener noreferrer\" target=\"_blank\">Using Fetch<\/a><\/li>\n<p>In no-cors mode only the following are allowed<\/p>\n<ul>\n<li>Accept<\/li>\n<li>Accept-Language<\/li>\n<li>Content-Language<\/li>\n<li>Content-Type which can only take the following\n<ul>\n<li>application\/x-www-form-urlencoded<\/li>\n<li>multipart\/form-data<\/li>\n<li>text\/plain<\/li>\n<\/ul>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind. If you&#8217;re using the Javascript fetch api with mode set to &#8216;no-cors&#8217; beware that this limits the set of headers you can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[45],"tags":[],"class_list":["post-8565","post","type-post","status-publish","format-standard","hentry","category-javascript"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8565"}],"version-history":[{"count":3,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8565\/revisions"}],"predecessor-version":[{"id":9568,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8565\/revisions\/9568"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}