Page MenuHomePhabricator

Rely on function `makeApiCall` for API calls
Closed, ResolvedPublic

Description

As per discussion in 655550, for handling promises generated as a result of API calls more consistently, Swagger.js file was added, which includes:

export function makeApiCall( context, request ) {
	request.headers = request.headers || {};
	request.headers[ 'Content-Type' ] = 'application/json';
	if ( request.method !== 'GET' ) {
		request.headers[ 'X-CSRFToken' ] = context.state.user.csrf_token;
	}

	return SwaggerClient.http( request );
}

Currently only store/user.js makes use of this function. Ideally remaining store files also rely on it.