What is fetch API?

Bruce Gust
Bruce Gust used Ask the Experts™
I'm going through a tutorial and I want to better understand what "fetch()" is.

The instructor references it as "fetch API" and I am working in a Vue.js context. When I go to google it, I get some Javascript and some npm hits, but I wanted to confirm with some minds greater than my own exactly what this is.

Here's my code:

		<nav aria-label="Page navigation example">
			<ul class="pagination">
				<li v-bind:class="[{disabled: !pagination.prev_page_url}]" class="page-item">
				<a class="page-link" href="#"
				<li class="page-item disabled"><a class="page-link text-dark" href="#">
				Page {{ pagination.current_page }} of {{ pagination.last_page }}</a></li>
				<li v-bind:class="[{disabled: !pagination.next_page_url}]" class="page-item">
				<a class="page-link" href="#"
		<div class="card card-body mb-2" v-for="article in articles" v-bind:key="article.id">
			<h3>{{ article.title }}</h3>
			<p>{{ article.body }}</p>

	export default {
		data() {
			return {
				articles: [], 
				article: {
					id: '',
					title: '',
					body: ''
				article_id: '',
				pagination: {},
				edit: false
		created() {
		methods: {
			fetchArticles(page_url) {
			let vm = this;
			page_url = page_url || '/api/articles'
					.then(res => res.json())
					.then(res=> {
						this.articles = res.data;
						vm.makePagination(res.meta, res.links);
					.catch(err => console.log(err));
			makePagination(meta, links) {
				let pagination = {
					current_page: meta.current_page,
					last_page: meta.last_page,
					next_page_url: links.next,
					prev_page_url: links.prev
				this.pagination = pagination;

Open in new window

I'm looking at line #47. Is it this: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chief Technology Ninja
Distinguished Expert 2018
Hi Bruce,

Yes. It is the same one.

It is a promise based mechanism to facilitate modern HTTP request / response scenarios. The page you have mentioned is actually a really good reference point to start understanding Fetch in detail.

Bruce GustPHP Developer


Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

You are welcome :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial