æ®æ®µaxiosã使ãã¨ãã¯ã¬ã¹ãã³ã¹ãJSONãªAPIãå©ããã¨ãå¤ãããHTMLãåå¾ãã¦æ¿å
¥ãããã¨ãããã¨æããinnerHTML
ã§ç´æ¥æ¿å
¥ãããã¨ãã§ããããresponseType
ãdocument
ã«ãããã¨ã§appendChild
ã§è¦ç´ ãæ¿å
¥ãããã¨ãã§ããã
import axios from 'axios'; axios({ method : 'GET', url : '/api/response/as/html', params : { hoge: 'fuga' }, responseType : 'document', }) .then((res) => { const body = document.querySelector('body'); Array.from(res.data.body.childNodes).forEach((node) => { body.appendChild(node); }); });